AutoFilter

tuongtu3

New Member
Joined
Dec 27, 2018
Messages
5
Hi,
I found the code from this forum and trying to test but got error message:

VBA Code:
       Sub LoopEachName()
Dim aNames As Variant, Itm As Variant

With Range("A1", Range("A" & Rows.Count).End(xlUp))
.AdvancedFilter Action:=xlFilterInPlace, Unique:=True
aNames = .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlVisible).Value
[COLOR=rgb(184, 49, 47)][B]For Each Itm In aNames   <=== I got error message from this line[/B][/COLOR]
.AutoFilter Field:=1, Criteria1:=Itm

'Do whatever you want with an individual name here

Next Itm
.AutoFilter
End With
End Sub
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
VBA Code:
aNames = .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlVisible).Value

Try modifying like

VBA Code:
aNames = .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).Value

Are youe sure the code you copied worked for the user who posted it?
 
Upvote 0

Forum statistics

Threads
1,213,532
Messages
6,114,177
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top