Discussion Locked

Excel Macro For Worksheets

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Is there an Excel(97/2000) formula that will place the Worksheet name (from the tab) into a cell automatically?

The macro below performs this, but you have to run the macro after each name change.

I was looking at whenever the worksheet name is changed or a worksheet copied, the cell's information changed automatically.

Sub pubPopulateName()
ActiveCell.Value = ActiveSheet.Name
End Sub

3 replies

by sheryl v

You have to put that piece of code on an "On Change" Event or the likes. Probably use an if statement to validate that the sheet name changed. Use a static variable array that grabs the current sheet names when the workbook opens "On Open Event" maybe.

In the vb editor press f1 type in "sheetchange event"

Hope this helps.

This discussion is closed to new replies.