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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top