Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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
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
Looping a selection of rows Andre Kruger Excel Discussion (Misc queries) 1 December 15th 05 04:18 PM
Looping through visible rows only Rasmus[_3_] Excel Programming 1 April 10th 05 02:08 AM
Looping through range newbie question Frank Rizzo Excel Programming 1 November 4th 04 12:09 AM
Looping through Ranges of Rows MS News Excel Programming 0 December 8th 03 11:42 AM
Newbie : Autofilter thru code ? Rich[_16_] Excel Programming 2 October 5th 03 07:27 PM


All times are GMT +1. The time now is 09:17 PM.

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"