How do i include " in text in a vba filter

Tucker92

Board Regular
Joined
Jun 7, 2018
Messages
53
I am trying to use an auto filter on my information but the criteria is 12"MET and i don't know how to allow for this in my code because of the quote marks.

Is there anyway i can do this or is there a way my filter can search for the 12 and then the MET and return all the results that contain both?

Help me please

Thank you
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hello Tucker92,

Try setting up the whole criteria as follows:-

Code:
12 & """" & "MET"

e.g.:-

Code:
Range("A2:A15").AutoFilter 1, 12 & """" & "MET"

Obviously, you'll need to add your range and autofilter field to suit.

I hope that this helps.

Cheerio,
vcoolio.
 
Upvote 0
Thank you. Its not coming up with the error anymore.

The issue i have now is that 12"MET isn't the whole name in the column but the rest changes.

Can i make it find the results containing this rather than only this?
 
Upvote 0
Hello Tucker92,

From what you say, I'm assuming that 12"MET is a constant amongst other numbers and letters, such as:-

12"MET
AS12"METMN
DF12"METR45
etc...

If so, then perhaps the following will work for you:-
Code:
Range("A2:A15").AutoFilter 1, "*" & 12 & """" & "MET" & "*"

I hope that this helps.

Cheerio,
vcoolio.
 
Upvote 0
Just FYI, you don't really need concatenation there:

"*12""MET*"

should suffice as the criterion.
 
Upvote 0
Very true Rory. Thanks for the prompt/reminder.

I'm up too late doing this. Time to give it a rest.

Thanks again.

Cheerio,
vcoolio.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,695
Members
448,979
Latest member
DET4492

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