I have the following code that opens a csv file
It comes up with message canot find file.
The full name is BR1 EL Br1 EL Service RepairOrderRegister.csv
The start name for eg Br1 and the word service is important
I need to amend the code below using wilcard characters so I do not have to use the full name
It comes up with message canot find file.
The full name is BR1 EL Br1 EL Service RepairOrderRegister.csv
The start name for eg Br1 and the word service is important
I need to amend the code below using wilcard characters so I do not have to use the full name
Code:
TheFile = Dir(ThePath & "BR1 Service" & "*.csv")
Code:
Sub Open_Workbook()
ChDir ("C:\extract")
Sheets(2).Delete
Dim nb As Workbook, tw As Workbook, ts As Worksheet, TheFile As String, ThePath As String
ThePath = "C:\extract\"
TheFile = Dir(ThePath & "BR1 Service" & "*.csv")
If TheFile = "" Then Exit Sub
With Application
.ScreenUpdating = False
End With
Set tw = ThisWorkbook
Set ts = tw.ActiveSheet
Set nb = Workbooks.Open(TheFile)
nb.Sheets(1).Copy After:=Workbooks("BR1 Service Sales.xlsm").Sheets(1)
Sheets(2).Name = "Imported Data"
ChDir ("C:\my documents")
End Sub