J
John
I have a fairly simple find and loop set up to find and color certian rows.
Currently I see two problems: First, my code finds my find value, but does
not appear to meet my IF THEN criteria. Meaning it has added color to a
row that does not meet this criteria in my code... If rngFound.Offset(0,
-11).Value > Sheets("data").Range("z4").Value Then "Color the row"... Is my
offset the wrong number? I have my find column in column U and the value I
am picking in the offset is in column J... isn't that offset(0,-11)?
The other thing is that when it finds and colors the first row in the loop,
it then ends the code, instead of continuing to find the rest of the rows
that meet the criteria.
Here is the code Thanks for the help!
Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range
Sheets("corps").Select
Call FindErrors
Range("u10").Select
Selection.EntireColumn.Hidden = False
Set wks = Sheets("corps")
Set rngToSearch = wks.Range("u11:u712")
Set rngFound = rngToSearch.find(what:="1", LookIn:=xlValues,
lookat:=xlWhole)
If rngFound.Offset(0, -11).Value > Sheets("data").Range("z4").Value Then
saddr = rngFound.Address
r = rngFound.Row
Do
Range("a" & r, "s" & r).Select
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound Is Nothing Or rngFound.Address = saddr
Range("u10").Select
Selection.EntireColumn.Hidden = True
end if
end sub
Currently I see two problems: First, my code finds my find value, but does
not appear to meet my IF THEN criteria. Meaning it has added color to a
row that does not meet this criteria in my code... If rngFound.Offset(0,
-11).Value > Sheets("data").Range("z4").Value Then "Color the row"... Is my
offset the wrong number? I have my find column in column U and the value I
am picking in the offset is in column J... isn't that offset(0,-11)?
The other thing is that when it finds and colors the first row in the loop,
it then ends the code, instead of continuing to find the rest of the rows
that meet the criteria.
Here is the code Thanks for the help!
Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range
Sheets("corps").Select
Call FindErrors
Range("u10").Select
Selection.EntireColumn.Hidden = False
Set wks = Sheets("corps")
Set rngToSearch = wks.Range("u11:u712")
Set rngFound = rngToSearch.find(what:="1", LookIn:=xlValues,
lookat:=xlWhole)
If rngFound.Offset(0, -11).Value > Sheets("data").Range("z4").Value Then
saddr = rngFound.Address
r = rngFound.Row
Do
Range("a" & r, "s" & r).Select
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound Is Nothing Or rngFound.Address = saddr
Range("u10").Select
Selection.EntireColumn.Hidden = True
end if
end sub