How do I, in VBA, test to see if a cell has a specific word in it

  • Thread starter Thread starter The Inspector
  • Start date Start date
T

The Inspector

I need to know what text is in an cell. The cell will be used to determine
what sheet will be edited with the macro.
 
Sub SelectSheet()
If ActiveCell.Value = MyValue Then
Sheets("MyValue").Select
Else
Sheets("NotMyValue").Select
End If
End Sub

Hope this helps.
 
do you mean

If ActiveCell.Value = "MyValue" Then

otherwise MyValue becomes a variable, defaulting to null and the IF
condition will always be False
 
Thanks guys

Patrick Molloy said:
do you mean

If ActiveCell.Value = "MyValue" Then

otherwise MyValue becomes a variable, defaulting to null and the IF
condition will always be False
 
Back
Top