hi there, i'm using a excel macro. how can i get the name of the worksheet so i can parse it as a variable as below
.[Worksheet_name]
..Name|" & name
..Description|" & desc
Say the name of my worksheet is tag. thank you
Printable View
hi there, i'm using a excel macro. how can i get the name of the worksheet so i can parse it as a variable as below
.[Worksheet_name]
..Name|" & name
..Description|" & desc
Say the name of my worksheet is tag. thank you
Use the Sheets collections.
VB Code:
Dim strName As String strName = ActiveWorkbook.Sheets(1).Name 'Assumes that the sheet you want is the first one in the Sheets collection.
Here is something to play with ...Code:Option Explicit
Sub Macro1()
Dim aSheet As Worksheet
Dim tstr As String
For Each aSheet In Sheets
tstr = aSheet.Name
MsgBox tstr
Next
End Sub