mayday1
Board Regular
- Joined
- Oct 5, 2007
- Messages
- 241
A kind soul helped me out with this the other day. Now I have a subsequent question: How do I set a variable to this value?
Here's what I'm trying to do:
Set MyFile = Workbooks(" & Range("B1") & " " & Range("C1") & ".xlsx")
so it would end up being:
Set MyFile = Workbooks(Donors April.xlsx)
-----
Here's the original question and the brilliant answer:
OK, so I have a drop down in cell A1 to select the year and another dropdown in B1 to select the first part of a filename and a third dropdown in C1 to select the second part of the filename
So if select...
A1 = 2019
B1 = Donors
C1 = April
...and the file I want to open is E:\ReportFolder\2019\Donors April.xlsx
What would be the VBA to open this file?
Below was the answer provided - works great for the original question.
Workbooks.Open ("E:\ReportFolder" & Range("A1") & "" & Range("B1") & " " & Range("C1") & ".xlsx")
Here's what I'm trying to do:
Set MyFile = Workbooks(" & Range("B1") & " " & Range("C1") & ".xlsx")
so it would end up being:
Set MyFile = Workbooks(Donors April.xlsx)
-----
Here's the original question and the brilliant answer:
OK, so I have a drop down in cell A1 to select the year and another dropdown in B1 to select the first part of a filename and a third dropdown in C1 to select the second part of the filename
So if select...
A1 = 2019
B1 = Donors
C1 = April
...and the file I want to open is E:\ReportFolder\2019\Donors April.xlsx
What would be the VBA to open this file?
Below was the answer provided - works great for the original question.
Workbooks.Open ("E:\ReportFolder" & Range("A1") & "" & Range("B1") & " " & Range("C1") & ".xlsx")