I am trying to open and activate a workbook from an already open workbook. I select a workbook to open using the Open Dialogue box as I don't know the location of the target file plus the name of the file changes regularly.
Once selected and open, I am not able to activate it to work on it.
My MsgBox is for testing and it shows the correct name of the target file but the active workbook remains that of the original file containing my code.
My code is
Sub openUpdate()
Dim strFile As String
On Error Resume Next
strFile = Application.GetOpenFilename(FileFilter:="Excel files (*.xl*),*.xl*", Title:="Select the Daily Update File")
strFile = Split(strFile, "\")(UBound(Split(strFile, "\")))
Workbooks(strFile).Activate
MsgBox (strFile & " " & ActiveWorkbook.Name)
End Sub
Once selected and open, I am not able to activate it to work on it.
My MsgBox is for testing and it shows the correct name of the target file but the active workbook remains that of the original file containing my code.
My code is
Sub openUpdate()
Dim strFile As String
On Error Resume Next
strFile = Application.GetOpenFilename(FileFilter:="Excel files (*.xl*),*.xl*", Title:="Select the Daily Update File")
strFile = Split(strFile, "\")(UBound(Split(strFile, "\")))
Workbooks(strFile).Activate
MsgBox (strFile & " " & ActiveWorkbook.Name)
End Sub