I have a workbook that I open and copy the data
I first want to open and delete all rows on sheet "Imported data" in Col N starting with Z1 & X1 eg Z100418 , X100419
If Z1 or X1 does not exist, then Exit Sub
I have tried to write code to do this , but get a run time error "Object does'nt support this property or method" and code below is highlighted
See full code below
It would be appreciated if someone could kindly assist me
I first want to open and delete all rows on sheet "Imported data" in Col N starting with Z1 & X1 eg Z100418 , X100419
If Z1 or X1 does not exist, then Exit Sub
I have tried to write code to do this , but get a run time error "Object does'nt support this property or method" and code below is highlighted
Code:
.AutoFilter
See full code below
Code:
Sub Open_File()
ChDir "C:\extract"
Dim A As Variant
Dim LR As Long
With Sheets("Imported Data")
.UsedRange.ClearContents
End With
If TypeName(A) = "Boolean" Then Exit Sub
Dim FileAry As Variant, Fle As Variant
With Application.FileDialog(3)
.InitialFileName = "C:\extract\"
.AllowMultiSelect = True
.InitialFileName = "Sales *BR*.xls*"
If .Show Then Set FileAry = .SelectedItems()
End With
For Each File In FileAry
If TypeName(A) = "Boolean" Then Exit Sub
With Workbooks.Open(File)
With .Sheets(1)
.Range("A1").AutoFilter 3, Array("Z1*", "", "X1*"), xlFilterValues
.AutoFilter.Range.Offset(1).EntireRow.Delete
.AutoFilter
.Range("a1", .Range("AH" & Rows.Count).End(xlUp)).Copy _
Destination:=ThisWorkbook.Sheets("Vat Analysis").Range("A" & Rows.Count).End(xlUp)
' .Range("a1:M" & Rows.Count).End(xlUp).UnMerge
End With
.Close savechanges:=False
End With
Next
Application.ScreenUpdating = True
End Sub
It would be appreciated if someone could kindly assist me