Hi,
Have the code below
and giving me this error
Run-time error '1004':
The extract range has a missing or invalid field name.
Attaching files:
Thank you,
Have the code below
VBA Code:
Sub Export_DCL_DATA()
Worksheets("EXPENSE").Range("A2:H14").ClearContents
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.ButtonName = "Open Raw Data"
.Filters.Clear
.Filters.Add "Excel Files", "*.csv"
.Filters.Add "CSV File", "*.csv"
.Title = "File Save As"
.Show
Application.ScreenUpdating = False
If .SelectedItems.Count Then
strFileSelected = .SelectedItems(1)
Else
MsgBox "Cancelled by user!"
Exit Sub 'Ideally, should exit from the bottom of the sub-routine.
End If
End With
fncFileSelected = strFileSelected
'Need a code here that will lookup the content of the file being opened and will copy and paste them the EXPENSE_TEMPLATE.xlsm
With Workbooks.Open(Filename:=fncFileSelected, ReadOnly:=True)
.Sheets(1).Cells(1).End(xlToRight).Offset(, 2).Resize(, 4).Value = ThisWorkbook.Worksheets("EXPENSE").Range("A1:H1").Value
.Sheets(1).Cells(1).CurrentRegion.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=.Sheets(1).Cells(1).End(xlToRight).Offset(, 2).CurrentRegion, Unique:=False
With .Sheets(1).Cells(1).End(xlToRight).Offset(, 2).CurrentRegion
ThisWorkbook.Worksheets("EXPENSE").Range("A1:H1").Resize(.Rows.Count, .Columns.Count).Value = .Value
End With
Workbooks(.Name).Close 0
End With
Application.ScreenUpdating = True
End Sub
and giving me this error
Run-time error '1004':
The extract range has a missing or invalid field name.
Attaching files:
Thank you,