Work sheet names and VBA macros in Excel
Work sheet names and VBA macros in Excel
(OP)
Hi,
I have a question about worksheet names and VBA macros in Excel. Is it possible to change the name of a worksheet in Excel (the name that can be seen in the bottom of the page) whiteout changing the VBA macros connected to them?
Thanks in advance/ Markus
I have a question about worksheet names and VBA macros in Excel. Is it possible to change the name of a worksheet in Excel (the name that can be seen in the bottom of the page) whiteout changing the VBA macros connected to them?
Thanks in advance/ Markus





RE: Work sheet names and VBA macros in Excel
Yes! Many of the better Excel VBA programming books recommend this, since your macro code will break, otherwise, if the user changes a sheet tab name. Here's how:
In the Visual Basic Editor (VBE), select the worksheet your macro code interacts with from the Project window. Notice that the Name property for the worksheet (Properties window) is the same as the current sheet tab name. Highlight this name and change it to whatever you want. Now your code can reference the worksheet as it would any other object. Here is some example code, where the worksheet name has been changed to Main as instructed above:
CODE
Dim Total As Single
Total = Main.Cells(4,1).Value
...
...
End Sub
Regards,
Mike
RE: Work sheet names and VBA macros in Excel
RE: Work sheet names and VBA macros in Excel
RE: Work sheet names and VBA macros in Excel
If you have code like
CODE
Regards,
Mike