Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if statement with wildcards

Status
Not open for further replies.

andyfresh

Technical User
Oct 4, 2005
33
GB
Hi,

I currently have a spreadsheet whereby I would like to use the following code however im unsure on how to create the IF statement.


Range("L940").Select
If ActiveCell Like "*" And ActiveCell.Offset(0, 1).Range("A1").Value And " " And "*" Then
MsgBox ("correct")
Else
MsgBox ("incorrect")
End If

The above statement currently produces an error.
Its meant to say if activecell is like the cell next to it with a wild card either side then the msgbox appears

Any help would be appreciated.

Regards

Andy
 
try this
Code:
If InStr(ActiveCell.Offset(0, 1).Text, ActiveCell.Text) > 0 Then
 MsgBox "text found"
Else
 MsgBox "text not found"
End If
 
If x Like "ggg" And y = "" And z = "*" Then
'
End If

would be the syntax for the if statement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top