I would like my loop to evaluate values in a range and proceed if the value is non-zero and a whole integer. My range also contains alpha-numeric values and I would like those to be ignored.
My loop is getting stuck when I hit one of those alpha-numeric values. How do I fix?
My code:
Dim r2 As Range
Dim fnd As Range
Dim Answer3 As String
For Each r2 In WorkRng2
If r2.Value <> "" And WorksheetFunction.IsNumber(r2.Value) And r2.Value = Int(r2.Value) Then
Set fnd = WorkRng1.Find(what:=r2.Value, LookIn:=xlValues)
If fnd Is Nothing Then
'nothing found
Answer3 = MsgBox("Cannot proceed! Major task " & r2.Address & " could not be found in invoice review file!", vbOK, "Question!")
If Answer3 = vbOK Then
Exit Sub
Else
'fnd holds the cell that was found
End If
End If
End If
Next
Also, WorkRng1 and WorkRng2 are public variables
Aucun commentaire:
Enregistrer un commentaire