VBA to advance to next unique criteria in Autofilter list

KB_02

New Member
Joined
Sep 7, 2018
Messages
26
I am trying to write a macro that will advance to the next unique criteria in an autofilter list.

I have roughly 2500 rows of data, but only need to filter by one criteria: The company name.

Using the Macro recorder to switch from Company A to Company B, I get this:
Code:
ActiveSheet.Range("$A$4:$A$2500").AutoFilter Field:=1, Criteria1:= _"Company Name B"

In the spread sheet I could have over 250 company names, but I sometimes have the need to go through them one by one to pull all data for each company. I currently just use the auto filter, but it takes some considerable time to pull down the list, deselect and then re-select the next name.

Is there a way to tell the criteria to just look for the next unique value in the list?
 
Last edited:
I GOT IT!

I figured it out. I had to replace (xlUp) with (xlDown).

Thanks, again, for your help! It works just like I want it to now.
Which code are you talking about? Fluff's or mine?
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,223,911
Messages
6,175,326
Members
452,635
Latest member
laura12345

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