How can I get a worksheet object from a specific workbook (not 'ThisWorkbook') using the worksheets CodeName?
问题 I want to obtain a worksheet object from a specific workbook, like so: Set ws = Application.Workbooks("WorkBookName.xlsm").Worksheets("sheet1") However, I want to use the CodeName of the worksheet since the sheet's name can be changed. For example: Set ws = Application.Workbooks("WorkBookName.xlsm").Sheet1 Now, I know this doesn't work since Sheet1 is a global variable create by the VBA editor for convenience. I also know I could use the index (i.e. Worksheets(1)) to obtain the worksheet