Adding full Range to Code

Nlhicks

Board Regular
Joined
Jan 8, 2021
Messages
244
Office Version
  1. 365
Platform
  1. Windows
Sub Test2()

Dim sh4 As Worksheet, sh3 As Worksheet
Dim cc As Range
Application.ScreenUpdating = False

Dim cellESIL As Range, strESIL$, strPassFail$, stResult As String
Dim varFindRequirement As Variant, lngFindRequirement&
Dim cellEasy As Range, strEasy$
Dim varFindScenario As Variant, lngFindScenario&

Set sh3 = ThisWorkbook.Worksheets("Sheet3")
Set sh4 = ThisWorkbook.Worksheets("Sheet4")

For Each cellESIL In sh4.Columns(1).SpecialCells(2)
Set varFindRequirement = Nothing
strESIL = Trim(cellESIL.Value)
strPassFail = Trim(cellESIL.Offset(, 1).Value)

Set varFindRequirement = sh3.Columns(8).Find(What:=strESIL, LookIn:=xlFormulas, LookAt:=xlWhole)
If varFindRequirement Is Nothing Then GoTo skipA
lngFindRequirement = varFindRequirement.Row

For Each cellEasy In sh4.Columns(3).SpecialCells(2)
Set varFindScenario = Nothing
strEasy = cellEasy.Value
Set varFindScenario = sh3.Rows(5).Find(What:=Trim(strEasy), LookIn:=xlFormulas, LookAt:=xlWhole)

If varFindScenario Is Nothing Then GoTo skipB
If Not varFindScenario Is Nothing Then
lngFindScenario = varFindScenario.Column
'Modify thse column number boundaries as needed.
If lngFindRequirement >= 6 And lngFindRequirement <= 19 Then
If lngFindScenario >= 9 And lngFindScenario <= 16 Then

If varFindScenario.Column And strPassFail = "Pass" Then
stResult = "+"
Else
stResult = "-"
End If

Set cc = sh3.Cells(lngFindRequirement, lngFindScenario)

If Len(cc.Value) = 0 And cc.Interior.ColorIndex = -4142 Then cc.Value = stResult
End If
End If
End If
skipB:
Next cellEasy
skipA:
Next cellESIL

Set varFindRequirement = Nothing
Set varFindScenario = Nothing
Set sh3 = Nothing
Set sh4 = Nothing
Set cc = Nothing
Set cellEasy = Nothing
Set cellESIL = Nothing

Application.ScreenUpdating = True
MsgBox "Completed.", , "Done."

End Sub

1631646932378.png
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
I believe this part is a hold-over from one of your previous questions
VBA Code:
'Modify thse column number boundaries as needed.
If lngFindRequirement >= 6 And lngFindRequirement <= 19 Then
If lngFindScenario >= 9 And lngFindScenario <= 16 Then
try removing it, or at least follow the comment bob put in
 
Upvote 0
I did change the range but Bob said that it may not work once it got extended to the full range. I changed everything to work and it is not working when I apply it to the full spectrum.
 
Upvote 0
I changed that code to If longFindRequirement >=6 And lngFindRequirement<=145 Then
If lngFindScenario>=6 And lngFindScenario<=75 Then
 
Upvote 0
Never mind when I expanded the limits on the practice sheet it works so I just have to double check my work Maybe it is a typo.
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,701
Members
448,980
Latest member
CarlosWin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top