Macro 1 code is stored in Workbook 1. Command button 1 triggers opening a user selected workbook. Let's call that Workbook 2 (although the actual Workbook name is different each time). Macro 1 runs codes (mostly formatting commands) in Workbook 2.
Macro 1 ends. Workbook 2 remains open. After some manual intervention by user on Workbook 2, user clicks Command button 2 in Workbook 1, which triggers Macro 2.
Macro 2 starts by activating Workbook 2 again, running code. At one point, code says to Open another user selected Workbook. Let's call it Workbook 3 (again, filename can be different). Then Macro 2 has codes that takes actions back in Workbook 2. Then goes back to Workbook 3.
The problem I am having is I cannot figure out how to Dim each of these workbooks given the Workbook names/WorkSheet names change. Also, with new Workbooks being opened at different points, I am not sure which parts of which Modules I need to add code.
.Selectand.Activateto go between them? You can create workbook/worksheet variables to store that info...e.g.Dim dataWB as Workbook//Dim mainDataWS as Worksheetand go from there. What have you tried so far? The workbook name changing can be easily dealt with, but we'd need a little more insight to how your macros work. If you can post the relevant parts of your code, it would help..Selectand.ActivateI am confused on if I can Dim workbooks and worksheets before they are opened. And if I should place these codes in the Module or in the Worksheet of Workbook 1 where I have the Command Button sub.Dim wbk As Workbooks Set wb2 = Active.wbk '(Workbook 2) that is already open '~~> Get the File MsgBox "Locate MICROSTRATEGY REPORT" Ret1 = Application.GetOpenFilename("Excel Files (*.xls*), *.xls*", _ , "Please select file") If Ret1 = False Then Exit Sub wbk.Open (Ret1) '(workbook 3)' wb2.Activate