Hi, newbie here...
I see in various tutorials that worksheets can be referred to by number, or name, or code name. Suppose I have a worksheet named "Data" whose code name is Sheet3. I'd like to assign a variable name (let's say "MySheet") to this worksheet, so that I can simply use MySheet in my macro instead of typing ThisWorkbook.Worksheets("Data"). But I would also like my macro to always refer to that sheet (even if the user moves it or renames it), so I'd like to define MySheet using the code name rather than the worksheet name (Data). Unfortunately, when I use code like this:
I get a compile error (Method or data member not found)! How can Sheet3 be "not found" when it's right there in the workbook? If I use this:
it works fine. But I want to use the code name rather than the worksheet name! What am I doing wrong?? Don't Worksheets("Data") and Sheet3 both refer to the same object?!?
Bookmarks