Travelling cell values with filter in Excel macro.

N

Nagarajan

In Excel, say i have two columns :

COl1 Col2
A 1
B 2
C 3
A 2
D 2
C 1
A 4

I apply filter to both columns. I filter Col1 data by choosing 'A'. COl2
then filters to 1,2,4. I have written the following macro to move from the
first cell value of Col1 to the last cell of the column after the data is
filtered.
-----------------------------------------------
Sub test()
Range("A2").Activate
While ActiveCell.Value <> ""
MsgBox ActiveCell.Value
ActiveCell.Offset(1, 0).Activate
Wend
End Sub
 
V

Vergel Adriano

Nagarajan,

Try it this way:

Sub test()
Dim lRow As Long
lRow = 2
While Range("A" & lRow).Value <> ""
If Not Range("A" & lRow).Rows.Hidden Then
MsgBox ActiveCell.Value
End If
lRow = lRow + 1
Wend
End Sub
 

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