Ok, so here's the deal. I'm trying to make a macro, that in part renames an existing worksheet. Before this macro is run, the worksheet is the only worksheet that exists in the file. The only problem is the worksheet's name changes depending on which file I open. And everytime I record the macro, the VB code comes out as
"Sheets("SheetABC").Select
Sheets("ABC").Name = "newname"
The problem is in other files that this macro needs to be used on, the sheet is named BCA or XYZ or whatever. so the macro goes to select sheetABC but it's not there, because it has a different name, and I get an error message.
What the heck would the code be to make Excel always select the 1 worksheet that exists in each file, and rename it to 'newname'???
Bookmarks