robertdseals
Active Member
- Joined
- May 14, 2008
- Messages
- 333
- Office Version
- 2010
- Platform
- Windows
Hello all,
I'm trying to use variables in a path name.
Dim MyFolder As String, MyFile As String
Dim MyCasino As String
Dim MyMonth As String
MyCasino = InputBox("which casino i.e. MR")
MyMonth = InputBox("which month i.e. 06")
MyFolder = "M:\Division of Gaming\GPI\MyCasino\2015\MyMonth"
MyFile = Dir(MyFolder & "\*.xls")
Do While MyFile <> ""
Workbooks.Open Filename:=MyFolder & "\" & MyFile
Part of the path to the folder includes MR, JP or BA and the month can be 01, 02, 03...
the formula ="M:\Division of Gaming\GPI\MR\2015\05" works, but not when I try to substitute MR with MyCasino or the 05 with "MyMonth".
I'm trying to use variables in a path name.
Dim MyFolder As String, MyFile As String
Dim MyCasino As String
Dim MyMonth As String
MyCasino = InputBox("which casino i.e. MR")
MyMonth = InputBox("which month i.e. 06")
MyFolder = "M:\Division of Gaming\GPI\MyCasino\2015\MyMonth"
MyFile = Dir(MyFolder & "\*.xls")
Do While MyFile <> ""
Workbooks.Open Filename:=MyFolder & "\" & MyFile
Part of the path to the folder includes MR, JP or BA and the month can be 01, 02, 03...
the formula ="M:\Division of Gaming\GPI\MR\2015\05" works, but not when I try to substitute MR with MyCasino or the 05 with "MyMonth".