ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Need some macro help. (https://www.excelbanter.com/excel-worksheet-functions/156778-need-some-macro-help.html)

tweacle[_4_]

Need some macro help.
 

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




--
tweacle

Dave Peterson

Need some macro help.
 
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.

tweacle wrote:

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

--
tweacle


--

Dave Peterson


All times are GMT +1. The time now is 01:15 PM.

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