I am trying to copy data from one workbook to my current workbook using VBA. InputBook is a workbook object related to the file from which I would like to extract data. The main problem is with reference to specific worksheets in the InputBook. In InputBook, I have a worksheet called "Lines", codenamed LINES. I would prefer to reference this worksheet under my codename, for example:
NumItems = WorksheetFunction.CountA(InputBook.LINES.Columns(1))
This obviously does not work, and I know that I can make it a function using one of the following actions:
NumItems = WorksheetFunction.CountA(InputBook.Sheets("Lines").Columns(1))
NumItems = WorksheetFunction.CountA(InputBook.Sheets(2).Columns(1))
I would rather not use any of these methods, as they seem less reliable. Is there a way to refer to the code name of a worksheet object in another open workbook? Thank.
source
share