Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading autofiletered data

Status
Not open for further replies.

jcf27

IS-IT--Management
Aug 24, 2002
21
0
0
US
I wrote some basic code to process data from a simple spreadsheet of 3 columns. So far, no problems.

The user incorporated an autofiler.

How do I make the code recognize only the auto filtered data as opposed to the whole sheet?

For example -- TOTRows = SheetA.UsedRange.Rows.Count still returns the total number of rows and not the ones displayed.

thanks in advance !

Jorge
(green programmer)
 
Try this:
Selection.SpecialCells(xlCellTypeVisible).Rows.Count

Thanks,

Gavin
 
Gavin,

Thanks for the reply. For some reason it did not work. It returned 1; where in actually, after the filter is selected, there are 200 lines or so. Here is part of my original code (I have 2 active sheets).

SheetARows = SheetA.UsedRange.Rows.Count

For Sheet_A_Row = 2 To SheetARows
(I do my stuff in here...)
Next SecuritiesRow

Based on -- Selection.SpecialCells(xlCellTypeVisible).Rows.Count ; the idea is to only loop through the visible lines. It didn't work :-(

Any other suggestions?

Thanks

Jorge
 
Hi Jorge
It may depend on what you want to do but you could use something like this

Code:
Dim c As Range
For Each c In ActiveSheet.UsedRange.Columns(1).SpecialCells(xlCellTypeVisible)
    Debug.Print c.Row, c.Value
Next


;-)
If a man says something and there are no women there to hear him, is he still wrong? [ponder]
How do I get the best answers?
 
And this ?
TOTRows = SheetA.UsedRange.SpecialCells(xlCellTypeVisible).Rows.Count

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Jorge - keyword in the code was SELECTION
PHV's 1 liner should do the trick for you

Rgds, Geoff

"Three things are certain: Death, taxes and lost data. Guess which has occurred"

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top