Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Filtering in VBA

I need help with the Autofilter
I have data in worksheet "SheetA" Cells A6 to D6 that has a list of names
In worksheet "SheetB" I have data from A2 to BB2 and in column AD have a
list of names that should contain multiple instances of the names in
SheetA!A6-D6
I would like to apply a filter from on SheetB!AD that corresponds to the
contents of SheetA!A6 the "do some work" then loop back to the contents in
SheetA!B6 and reapply a filter to SheetB!AD and "do some more work with
contents"

Make any sense ?

I already have some code:

Worksheets("SheetA").Activate
Range("A6").Activate
sPort = Range("A6").Text
iColumn = 1
iRow = 1
Do While sPort < ""
'Do the filter bit here
'Loop to next value in A6 to D6
iColumn = iColumn + 1
sPort = Range("A6").Cells(1, iColumn).Text
Loop

As you may be able to see Im a bit of a newbie at VB so if someone can
provide any help it would be much appreciated

Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Filtering in VBA

Sub BCDE()
Dim rng As Range
Dim cell As Range
With Worksheets("SheetB")
Set rng = .Range(.Cells(1, "AD"), .Cells(Rows.Count, "AD").End(xlUp))
End With
For Each cell In Worksheets("SheetA").Range("A6:D6")
rng.AutoFilter 1, cell
' code that does something
MsgBox "cell: " & cell.Value
Next
rng.AutoFilter

End Sub

I assume there is a header in AD1. If not and you header is in AD2, then
change .Cells(1,"AD") to .Cells(2,"AD")

--
Regards,
Tom Ogilvy



"SteveW" wrote in message
...
I need help with the Autofilter
I have data in worksheet "SheetA" Cells A6 to D6 that has a list of names
In worksheet "SheetB" I have data from A2 to BB2 and in column AD have a
list of names that should contain multiple instances of the names in
SheetA!A6-D6
I would like to apply a filter from on SheetB!AD that corresponds to the
contents of SheetA!A6 the "do some work" then loop back to the contents in
SheetA!B6 and reapply a filter to SheetB!AD and "do some more work with
contents"

Make any sense ?

I already have some code:

Worksheets("SheetA").Activate
Range("A6").Activate
sPort = Range("A6").Text
iColumn = 1
iRow = 1
Do While sPort < ""
'Do the filter bit here
'Loop to next value in A6 to D6
iColumn = iColumn + 1
sPort = Range("A6").Cells(1, iColumn).Text
Loop

As you may be able to see Im a bit of a newbie at VB so if someone can
provide any help it would be much appreciated

Thanks




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
Filtering Susan Excel Worksheet Functions 6 July 25th 08 01:43 AM
Help with filtering... Ed Excel Worksheet Functions 1 March 13th 07 04:45 AM
Filtering J kannan Excel Discussion (Misc queries) 2 October 4th 06 01:12 PM
trouble filtering a list. Why isn't column filtering? Pat Excel Worksheet Functions 1 July 18th 05 03:30 PM
Filtering Dave Excel Discussion (Misc queries) 2 June 28th 05 09:43 PM


All times are GMT +1. The time now is 10:53 PM.

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

About Us

"It's about Microsoft Excel"