Help with FOR LOOP and and Advance Filter

A

Ayo

I was wondering if it is possible to use a:
For Each c in Range().Cells
to loop through an autofilter range or an advance filter range.

What I am trying to do is run an advance filter in place and use the For
Each c in Range().Cells loop through the filtered data and place the results
of the loop on another sheet in the worrkbook. Is this possible? If so, can
someone place give me an idea how to do this, please?
Thank you
Ayo
 
G

Gary Keramidas

i've used something like this snippet:

Set rng = Range(ws.Cells(2, "D"), ws.Cells(6,
"D").End(xlDown)).SpecialCells(xlCellTypeVisible)
For Each cell In rng
' do something
Next
 
A

Ayo

What exactly does this do? I am a bit confused with the Range(ws.Cells(2,
"D"), ws.Cells(6,"D").End(xlDown)) part espeecially the Range(ws.Cells(2,
"D"), ws.Cells(6,"D") part. Can you explain that part to me.
I am guessing that Range(ws.Cells(2, "D"), ws.Cells(6,"D") is the same as
Range(Cells(2, 4), (6,4). Is this correct? And if so, what does the
..End(xlDown) do?

Thanks again for the help.
 
G

Gary Keramidas

it was just an example of how to select a range. the end.down goes down to
the last filled cell and uses that and the last cell in the range. it just
used row 6 as the starting point.

like i said, it was just an example.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top