ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Advancedfilter (https://www.excelbanter.com/excel-programming/349158-advancedfilter.html)

Ram

Advancedfilter
 
When i try and use advance filter in my code it will only filter if I
activate the worksheet first.
Is there away to use advance filter with out activating the worksheet.

thanks for any help.



NA[_2_]

Advancedfilter
 
ram

i'm not sure what your stuff looks like, but below is a snip i wrote earlier
today that works. DATA and LIST are worksheet codenames.
the purists will slam me for sloppy code - but it was a quick fix and it
will give you the idea.
perhaps the solution is to make sure you identify the range you want to
filter.

rgds - voodooJoe

Private Sub Macro4()
'set and advance filter selected range for unique values
Set d =
DATA.Range("I1").Resize(rowsize:=Application.Works heetFunction.CountA(DATA.Columns(1).EntireColumn))
d.AdvancedFilter Action:=xlFilterInPlace, Unique:=True

'clear the target area
LIST.Range("a1").CurrentRegion.Offset(1, 0).ClearContents

'paste unique values to target area
d.Copy
LIST.Range("a1").PasteSpecial (xlPasteValues)

'turn off filter and copy mode
Application.CutCopyMode = False
d.Parent.ShowAllData

'sort the new list
With LIST.Cells(1, 1)
.CurrentRegion.Sort Key1:=.Cells(2, 1), Order1:=xlAscending,
Header:=xlYes, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom,
DataOption1:=xlSortNormal
End With

End Sub


"ram" wrote in message
...
When i try and use advance filter in my code it will only filter if I
activate the worksheet first.
Is there away to use advance filter with out activating the worksheet.

thanks for any help.






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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com