I want to activate another active (open) workbook only if its name is the same as what I have recorded in a cell in my workbook. If it does return the same name then it is activated, otherwise a message box displays.
Example:
In my Reports workbook on a worksheet name “formula” in cell B33, I have the value “JulyData”. This represents the name of another workbook (i.e. JulyData.xls)
Before a routine is run to import data into Reports.xls I want to verify that the name of the source workbook is actually “JulyData.xls” (as verified to B33 on my “formula” worksheet) and not “AugData.xls”. If it is “JulyData.xls” then I want the procedure to make it the active workbook and start importing data from selected cells. If it is not, then a message box will display.
I know this code doesn’t work:
TW = Worksheets("formula").Range("B33").Value
If Windows.Activate = TW Then Windows.Activate
MsgBox ("Error - Data workbook name does not match." & vbCr & _
"Select correct month for data import."), vbOKOnly, "Data", a, a
I need some help please
Example:
In my Reports workbook on a worksheet name “formula” in cell B33, I have the value “JulyData”. This represents the name of another workbook (i.e. JulyData.xls)
Before a routine is run to import data into Reports.xls I want to verify that the name of the source workbook is actually “JulyData.xls” (as verified to B33 on my “formula” worksheet) and not “AugData.xls”. If it is “JulyData.xls” then I want the procedure to make it the active workbook and start importing data from selected cells. If it is not, then a message box will display.
I know this code doesn’t work:
TW = Worksheets("formula").Range("B33").Value
If Windows.Activate = TW Then Windows.Activate
MsgBox ("Error - Data workbook name does not match." & vbCr & _
"Select correct month for data import."), vbOKOnly, "Data", a, a
I need some help please