I have a long macro, mostly recorded VBA.
It opens/closes various files as it proceeds
I need to select the correct workbook/sheet that refers back to..........
The MAIN file the macro operates on, the name of which changes every so often.
If i have an inputbox option at the start of the macro, to name the current workbook, which today, is.....
Bono.xlsb
and reuse it within the macro, when i am selecting the workbook, without having to type it in every time, its happy days
So at the start of the macro, i want this message box ONLY ONCE, and i type in the name of the new MAIN workbook
Perhaps a filepath could be entered into this box
So that when i want to do something like this......
Workbooks("Bono.xlsb").Activate
Sheets("top10hits").Select
It cannot be about "Bono.xlsb" because the file in 3 days time has a new name. It could be "Madonna" for example
what i type into this box, will replace "Bono.xlsb" in ''''''''Workbooks("Bono.xlsb").Activate''''''''''
so something like this
eg
Dim MAIN as Workbook
Set MAIN = InputBox("name this workbook, as 'Bono' is so yesterday", "InputBox Example")
Set MAIN = "Madonna.xlsb" - (imagined i typed this into the box)
then in the macro, it solves the issue of selecting the MAIN workbook, when i write something like this.......
Workbooks(MAIN).Activate
Sheets("top10hits").Select
but the macro is actually interpreting
Workbooks("Madonna.xlxb").Activate
Sheets("top10hits").Select
because i typed "Madonna.xlsb" into the Inputbox
in other words...
MAIN = what i type into the Inputbox, either name.fileextension or filepath
After searching, I still haven't found what I'm looking for.
is this possible?
i will also add, using the same filename each time, would be a last resort, due to other events and happenings, which would make it tedious at best.
Any ideas will be appreciated.
It opens/closes various files as it proceeds
I need to select the correct workbook/sheet that refers back to..........
The MAIN file the macro operates on, the name of which changes every so often.
If i have an inputbox option at the start of the macro, to name the current workbook, which today, is.....
Bono.xlsb
and reuse it within the macro, when i am selecting the workbook, without having to type it in every time, its happy days
So at the start of the macro, i want this message box ONLY ONCE, and i type in the name of the new MAIN workbook
Perhaps a filepath could be entered into this box
So that when i want to do something like this......
Workbooks("Bono.xlsb").Activate
Sheets("top10hits").Select
It cannot be about "Bono.xlsb" because the file in 3 days time has a new name. It could be "Madonna" for example
what i type into this box, will replace "Bono.xlsb" in ''''''''Workbooks("Bono.xlsb").Activate''''''''''
so something like this
eg
Dim MAIN as Workbook
Set MAIN = InputBox("name this workbook, as 'Bono' is so yesterday", "InputBox Example")
Set MAIN = "Madonna.xlsb" - (imagined i typed this into the box)
then in the macro, it solves the issue of selecting the MAIN workbook, when i write something like this.......
Workbooks(MAIN).Activate
Sheets("top10hits").Select
but the macro is actually interpreting
Workbooks("Madonna.xlxb").Activate
Sheets("top10hits").Select
because i typed "Madonna.xlsb" into the Inputbox
in other words...
MAIN = what i type into the Inputbox, either name.fileextension or filepath
After searching, I still haven't found what I'm looking for.
is this possible?
i will also add, using the same filename each time, would be a last resort, due to other events and happenings, which would make it tedious at best.
Any ideas will be appreciated.