Need some macro help.

T

tweacle

have a macro that I keep getting a error on. Can anyone help.

The macro shown below.

Sub Macro2()
'
' Macro2 Macro
'

'
Columns("J:J").Select
Selection.AutoFilter
ActiveSheet.Range("$J$1:$J$330").AutoFilter Field:=1, Criteria1:=Array(
_
"Days", "From", "Hrs", "Off", "On", "To"), Operator:=xlFilterValues
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.ClearContents
Range("J1").Select
End Sub

Ive put into my workbook and comes up with run time error 1004 auto
method of range class failed.

Can anyone help. Im using office XP if that helps.

Thanks
 
D

Dave Peterson

When you do Data|Filter|Autofilter (in xl2003 and below), you get 2 criteria.
You can't cheat excel and try to use an array in code.

I'd insert a new column (K???) and use a formula like:
=or(j2={"Days", "From", "Hrs", "Off", "On", "To"})
Then drag down.

Then you could filter to show Trues.
 

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

Similar Threads


Top