Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Travelling cell values with filter in Excel macro.

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
-----------------------------------------------

When the macro runs, all values under the column gets activated & displayed
in the message box. I would like to have the filtered value alone to be
shown. Do i need to change anything in the macro ?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Travelling cell values with filter in Excel macro.

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



"Nagarajan" wrote:

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
-----------------------------------------------

When the macro runs, all values under the column gets activated & displayed
in the message box. I would like to have the filtered value alone to be
shown. Do i need to change anything in the macro ?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Desperate for help in travelling salesman problem! krzys_28 Excel Discussion (Misc queries) 5 April 23rd 06 06:44 PM
How do I Auto-Filter with multiple values in a cell in Excel? Burghthing Excel Discussion (Misc queries) 2 November 23rd 05 04:41 PM
advanced filter macro to locate values via multiple criteria jjfjr[_2_] Excel Programming 1 November 8th 05 03:28 AM
Travelling from a formula to its source denny Excel Discussion (Misc queries) 2 July 8th 05 06:57 AM
Search/Filter to find values in another range based on two cell values Andy Excel Programming 2 April 29th 04 04:08 PM


All times are GMT +1. The time now is 01:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"