PLEASE help
Tom raises a good point about what to do with the result, which I did not
focus on AND subsequently left out. Here's something that might work better
if you want to act on the results separately from the test:
'Use the following sub to process your task.
'It calls the bCheckMyCells() function (modified version included here).
Sub CheckMyCells()
Dim r As Long, lNumRows As Long, lStartRow As Long
lStartRow = 2
lNumRows = lStartRow + 199
For r = lStartRow To lNumRows
If Cells(r, "F") < "" Then
If bCheckMyCells(r) Then
'do some OK thing
Else
'do some NOT OK thing
End If
End If
Next r
End Sub
'This is a revised version of my original concept using Cells()
' (borrowed from Tom's suggestion).
Function bCheckMyCells(ByVal Row As Long) As Boolean
Select Case ActiveSheet.Range("F" & Row).Value
Case Is = 10 And _
Cells(Row, "G") = Cells(Row, "D"): bCheckMyCells = True
Case Is = Cells(Row, "D") And _
Cells(Row, "G") <= Cells(Row, "D"): bCheckMyCells = False
Case Is < 10 And _
Cells(Row + 1, "E") = Cells(Row + 1, "D"): bCheckMyCells = True
Case Is < 10 And _
Cells(Row + 1, "E") < Cells(Row + 1, "D"): bCheckMyCells = False
End Select
End Function
Regards,
Garry
|