Using Like with "and" or "or"

Ed in Aus

Well-known Member
Joined
Jul 24, 2007
Messages
829
Hi everyone,

need a little help with a statement failing.

Code:
Cells(r, 1).Select
If ActiveCell.Value Like "*.*" Or "*$*" Then GoTo skippy

the current activecell = "Administration" but it brings back an error run time type 13...

not sure what I have done wrong
 
Last edited:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Rich (BB code):
If ActiveCell.Value Like "*.*" Or ActiveCell.Value Like "*$*" Then GoTo skippy
Try that.
 
Upvote 0
Bingo, thank you so much tried to google but it let me down this time... was much quicker to come in here for a change... usually find what I need out there.

Thanks again
 
Upvote 0
Hi Ed

You could also use a CharList:

Code:
If ActiveCell.Value Like "*[.$]*" Then GoTo skippy
 
Upvote 0
Thanks for that PGC can you explain what it is doing when you enter this just so I can use it for different scenarios not sure I follow what is happenening
 
Upvote 0
Hi again

You build a CharList by enclosing characters in square brackets. The pattern will mach any one of the characters in the CharList.

Ex:

"*[.$%_]*"

will match any string that includes any of the characters ".", "$", "%" or "_".

HTH
 
Upvote 0

Forum statistics

Threads
1,213,484
Messages
6,113,923
Members
448,533
Latest member
thietbibeboiwasaco

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top