Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
AutoFilter, Looping through the Rows? (Newbie)
Hi,
I've set an AutoFilter on Date and Company Name. COLUMNS: Date, Reference Number, Goods G-VAT, Cheque Number, Services S-VAT, New Balance, Previous Balance Company Name It selects 6 rows, as expected. I'm required to pre-process each row for certain column information, i.e. ignore Cheque Number and Previous Balance. How can I read into an array, a line at a time, and loop round all the selected Rows? Thanks in advance, Mark. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
AutoFilter, Looping through the Rows? (Newbie)
This may get you started:
Option Explicit Sub testme() Dim wks As Worksheet Dim rngF As Range Dim myCell As Range Set wks = ActiveSheet If wks.AutoFilterMode = False Then MsgBox "Please apply Data|Filter|Autofilter" Exit Sub End If With wks.AutoFilter.Range If .Columns(1).Cells.SpecialCells(xlCellTypeVisible). Count = 1 Then 'no visible cells, except for the header Else 'get visible cells from first column of filtered range Set rngF = .Resize(.Rows.Count - 1, 1) _ .Offset(1, 0).Cells.SpecialCells(xlCellTypeVisible) 'MsgBox rngF.Address For Each myCell In rngF.Cells 'MsgBox myCell.Address Next myCell End If End With End Sub It actually loops through the visible cells in the first column of the filtered range. Barton wrote: Hi, I've set an AutoFilter on Date and Company Name. COLUMNS: Date, Reference Number, Goods G-VAT, Cheque Number, Services S-VAT, New Balance, Previous Balance Company Name It selects 6 rows, as expected. I'm required to pre-process each row for certain column information, i.e. ignore Cheque Number and Previous Balance. How can I read into an array, a line at a time, and loop round all the selected Rows? Thanks in advance, Mark. -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
AutoFilter, Looping through the Rows? (Newbie)
Dim vArr(0 to 6)
i = -1 for each rw in ActiveSheet.Autofilter.Range.rows if rw.Entirerow.Hidden = False then i = i + 1 vArr(i) = rw.Cells(1,1).Value end if Next header row will be in varr(0) -- Regards, Tom Ogilvy "Barton" wrote in message ups.com... Hi, I've set an AutoFilter on Date and Company Name. COLUMNS: Date, Reference Number, Goods G-VAT, Cheque Number, Services S-VAT, New Balance, Previous Balance Company Name It selects 6 rows, as expected. I'm required to pre-process each row for certain column information, i.e. ignore Cheque Number and Previous Balance. How can I read into an array, a line at a time, and loop round all the selected Rows? Thanks in advance, Mark. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
AutoFilter, Looping through the Rows? (Newbie)
Thank you both for your replies. Hopefully my hair will grow back
in-time.... |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Looping a selection of rows | Excel Discussion (Misc queries) | |||
Looping through visible rows only | Excel Programming | |||
Looping through range newbie question | Excel Programming | |||
Looping through Ranges of Rows | Excel Programming | |||
Newbie : Autofilter thru code ? | Excel Programming |