I have a macro to open up a specfic file
I need the code amended to that if the first file specified (BR1EMK Branch Sales.csv) is not found then to select another specified file BR1NE branch sales.csv
I need this part of the code amended to accomodate my request
Your assistance is most appreciated
I need the code amended to that if the first file specified (BR1EMK Branch Sales.csv) is not found then to select another specified file BR1NE branch sales.csv
I need this part of the code amended to accomodate my request
Your assistance is most appreciated
Code:
TheFile = Dir(ThePath & "BR1EMK*Sales" & "*.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 & "BR1EMK*Sales" & "*.csv")
'If TheFile = False Or IsEmpty(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 Sales.xlsm").Sheets(1)
Sheets(2).Name = "Imported Data"
ChDir ("C:\my Documents")
End Sub