advanced filternot working in macro

T

tina

Hi
A macro with advanced filter is nolonger working the advance filter does not
give any data but if run manually with sames settings it works. Problem
seems to been since upgraded to office 2007 . I recorded a amcro for filter
and ran this and this failed to give data when macro ran but did when recorded
relevant code is
Range("MYCODES").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range _
("I1:I2"), CopyToRange:=Range("K1"), Unique:=False
any Ideas
Thanks Tina
 
C

Charlize

tina;557571 said:
Hi
A macro with advanced filter is nolonger working the advance filte
does not
give any data but if run manually with sames settings it works
Problem
seems to been since upgraded to office 2007 . I recorded a amcro fo
filter
and ran this and this failed to give data when macro ran but did whe
recorded
relevant code is
Range("MYCODES").AdvancedFilter Action:=xlFilterCopy
CriteriaRange:=Range _
("I1:I2"), CopyToRange:=Range("K1"), Unique:=False
any Ideas
Thanks TinaSub test()
'In excel 2007 you have to refer to every object. There are n
assumptions anymore
'Even if you are on the activesheet on which you want to perform a
action,
'you'll have to refer to it in your coding.
With ActiveWorkbook
With .ActiveSheet
.Range("MYCODES").AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=.Range("I1:I2"), CopyToRange:=.Range("K1")
Unique:=False
End With
End With
End SubCharliz
 
J

Joel

The ranges are probably referencing the wrong worksheet. The n amed Range is
probably ok, but the criteria range and copyto range are refering the
activeworksheet. the activesheet may be incorrect.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top