Reputation: 435
I'd like to make a loop with an if function in it. The condition for this if funtion needs to be the active cell containing a "*"or not.
-The If - like funtion does not work because the like function does not recognize "*" figures because it uses these to define parts of strings.
How do I return a True/False Boolean from an InStr function?
Upvotes: 2
Views: 13920
Reputation: 435
Do While ActiveCell.Value <>""
If InStr(ActiveCell.Value, "*") Then
MsgBox("Cell contains at least one '*'")
Else
End if
ActiveCell.Offset(1,0)
Loop
Upvotes: 4
Reputation: 1
Do While ActiveCell.Value <> ""
If InStr(ActiveCell.Value, "*") <> 0 Then
MsgBox("Cell contains at least one '*'")
Else
MsgBox("Cell does not contain at least one '*'")
End if
ActiveCell.Offset(1,0)
Loop
The String Expression either contains a location for the special character or not. If not, then the Instr returned value will be 0.
Upvotes: 0