Forum Home
Press F1
 
Thread ID: 13306 2001-11-30 02:47:00 Excel VB Macro Syntax Guest (0) Press F1
Post ID Timestamp Content User
26065 2001-11-30 02:47:00 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!
Guest (0)
26066 2001-11-30 05:26:00 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
Guest (0)
26067 2001-12-01 00:18:00 Thanks Russell. Works like a charm. Very grateful - I've got HUNDREDS to do! Guest (0)
1