Help with VBA Code to Loop through Filtered Items

mhague

New Member
Joined
Mar 20, 2002
Messages
14
I've been trying to figure this out for some time now. If I set the autofilter ON in VBA, is there a way to loop through the values that appear in my desired filtered column and have all the rows in the filter display?

I guess the question is: In VBA, how do you loop through items that you have in an filtered column? My goal is to pull up all the rows of filtered data, copy each group to another sheet, then move on to the next filtered item in the column.

Any help would be much appreciated!

Thanks, Marcie
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
The following procedure looks for visible cells in colA that have a constant in it. Any cell that is not visible due to a filter will be excluded.


Sub Demo()
With Columns("A:A")
rg1 = .SpecialCells(xlCellTypeVisible).Address
rg2 = .SpecialCells(xlCellTypeConstants, 3).Address
End With
For Each C In Application.Intersect(Range(rg1), Range(rg2))
MsgBox C.Value
Next C
End Sub
 
Upvote 0

Forum statistics

Threads
1,203,094
Messages
6,053,507
Members
444,667
Latest member
KWR21

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