Using Worksheet Name

A

Akhil Goel

I am having multiple worksheets in an Excel file and now I want to use the
name of each worksheet in a new worksheet in the same file.

Is there a formula which can copy the name of worksheet into a Cell of
another worksheet
 
D

Dave Peterson

Option Explicit
Sub testme()

Dim iCtr As Long
Dim rCtr As Long

rCtr = 0
For iCtr = 1 To Sheets.Count
If Worksheets(iCtr).Name = Worksheets("NewWorksheetname").Name Then
'skip it
Else
rCtr = rCtr + 1
With Worksheets("NewWorksheetname")
With .Cells(rCtr, "A")
.NumberFormat = "@" 'text
.Value = Sheets(iCtr).Name
End With
End With
End If
Next iCtr

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top