D
Dennis
I have a auto filtered worksheet and I would like to save just the visible to a
csv file of the same file name. Below is my Macro that gives me an error "Run
time Error 438, Object does not support this property" when it attemps to save.
The debug highlights the ActiveWorkbook.Sheets(1)... line. Thanks in advance
for any help in making this work.
Sub AutofilterAnSave()
Dim MyFileName As String
Dim MyNewFileName As String
Dim strlen As Integer
Rows("2:2").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:=">=8", Operator:=xlAnd
Selection.AutoFilter Field:=1, Criteria1:=">=6", Operator:=xlAnd
Selection.AutoFilter Field:=3, Criteria1:=">=0.8", Operator:=xlAnd
Selection.AutoFilter Field:=4, Criteria1:=">=0.8", Operator:=xlAnd
Selection.AutoFilter Field:=5, Criteria1:=">=0.5", Operator:=xlAnd
Application.DisplayAlerts = False
MyFileName = ActiveWorkbook.FullName
strlen = Len(MyFileName)
MyNewFileName = Left(MyFileName, strlen - 3) & "csv"
ActiveWorkbook.Sheets(1).AutoFilter.Visible.SaveAs filename:=MyNewFileName, _
FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub
csv file of the same file name. Below is my Macro that gives me an error "Run
time Error 438, Object does not support this property" when it attemps to save.
The debug highlights the ActiveWorkbook.Sheets(1)... line. Thanks in advance
for any help in making this work.
Sub AutofilterAnSave()
Dim MyFileName As String
Dim MyNewFileName As String
Dim strlen As Integer
Rows("2:2").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:=">=8", Operator:=xlAnd
Selection.AutoFilter Field:=1, Criteria1:=">=6", Operator:=xlAnd
Selection.AutoFilter Field:=3, Criteria1:=">=0.8", Operator:=xlAnd
Selection.AutoFilter Field:=4, Criteria1:=">=0.8", Operator:=xlAnd
Selection.AutoFilter Field:=5, Criteria1:=">=0.5", Operator:=xlAnd
Application.DisplayAlerts = False
MyFileName = ActiveWorkbook.FullName
strlen = Len(MyFileName)
MyNewFileName = Left(MyFileName, strlen - 3) & "csv"
ActiveWorkbook.Sheets(1).AutoFilter.Visible.SaveAs filename:=MyNewFileName, _
FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub