PDA

View Full Version : Excel VB Macro Syntax



30-11-2001, 02:47 PM
Could someone please give me the correct syntax to rename an Excel 97 worksheet from a cell on that worksheet?
For instance, cell A1 of worksheet Sheet1 contains the string 'ABCD'. I want to invoke a macro to rename the worksheet 'ABCD'.
I've used a variable to store the contents of A1, but can't find the right syntax for entering it on the worksheet tab.
Thanks!

30-11-2001, 05:26 PM
Try this macro

Sub RENAME_SHEET()

Dim NM As String
Dim NM2 As String

NM = ActiveSheet.Name
NM2 = ActiveSheet.Range('A1').Text
Sheets(NM).Name = NM2
End Sub

HTH

01-12-2001, 12:18 PM
Thanks Russell. Works like a charm. Very grateful - I've got HUNDREDS to do!