[VBA] Very noob question, how do I add a filter that checks if a column contains a word in VBA?

mvfsullivan

New Member
Joined
Dec 24, 2021
Messages
9
Office Version
  1. 2021
Platform
  1. Windows
TLDR: Excel filters dont seem to be consistent enough, I need to use VBA to search the word "Urgent" in a column and filter only those rows so my thing can do the thing :D

I know this has been asked a billion times before but none of the answers make sense to me and the solutions shared are massive for what the other users specific questions are. This should be a relatively tiny few lines of code right? All of the ones I'm seeing have like 10-15 lines.

I have a table of a bunch of stuff that is auto sorted using the command below, and I need another function that lets me activate filters because for some reason Excel likes to forget what it needs to filter.

My table relies on pasting external excel info into a table, and the rest of the tables search for words in order to count up statistics based on whats pasted. I am then using a main "stat table" that basically references random bits of stats.

To auto sort the "top issues" stuff I use (there are like 20 lines of "Range" to sort other tables but I just included one to keep things short):

Sub SortDataWithHeader()
Range("B648:B671").Sort Key1:=Range("B648"), Order1:=xlDescending
End Sub

From what I have read, the below is able to filter but it doesnt do anything:

Sub FilterOn()
Range("D1").AutoFilter field:=1, Criteria1:="*Urgent*"
End Sub

The word I need to filter for is the word Urgent, and the actual table range is O777 to O1077 (the header is at O776)

Please help :D

You can give a quick answer but if you could break down what you did and why that would be amazing. Its cool if you dont want to though, I know a ton of you guys are running around answering a billion questions and I truly truly appreciate that you are all helping make the world more productive!!! Hats off to you all, seriously!! <3
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Why are you filtering column D starting in cell D1 for the word Urgent that you expect to exist in column O in range O777:O1077.
 
Upvote 0
I figured it out, I just used Macro recorder to see what I was doing wrong. It was just a table reference thing.
 
Upvote 0
(In Mac OS at least: Tools > Macros > Record Macro, and then manually add a filter, stop the recording from the same area, and look at the new module in VBA editor)
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,241
Members
449,075
Latest member
staticfluids

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