A
Ashley
Hi,
I am creating a macro where the user will choose the xls
file to open. I then want to activate that file, but am
having some trouble figuring out how to write code to
specify which workbook to activate since the user will
choose the workbook and therefore I don't know it
beforehand.
Here is the code so far:
Dim fileToOpen
Dim fileName
fileToOpen = Application _
.GetOpenFilename("Microsoft Excel Files (*.xls),
*.xls")
Workbooks.Open fileName:=fileToOpen
'Workbooks("*****").Activate
I am not sure what to put where the asteriks are in the
last line of code.
I was thinking of finding the filename in the file path by
using the InStrRev to find where the \ is and take the
name between the \ and .xls, such as
InStrRev(fileToOpen, "\")
However, I thought there might be a better way that I
don't know about.
Any help would be much appreciated!
Thanks!
Ashley
I am creating a macro where the user will choose the xls
file to open. I then want to activate that file, but am
having some trouble figuring out how to write code to
specify which workbook to activate since the user will
choose the workbook and therefore I don't know it
beforehand.
Here is the code so far:
Dim fileToOpen
Dim fileName
fileToOpen = Application _
.GetOpenFilename("Microsoft Excel Files (*.xls),
*.xls")
Workbooks.Open fileName:=fileToOpen
'Workbooks("*****").Activate
I am not sure what to put where the asteriks are in the
last line of code.
I was thinking of finding the filename in the file path by
using the InStrRev to find where the \ is and take the
name between the \ and .xls, such as
InStrRev(fileToOpen, "\")
However, I thought there might be a better way that I
don't know about.
Any help would be much appreciated!
Thanks!
Ashley