Ship72
Ship72

Reputation: 93

Set cell contents to sheet name

Simple question for you experts out there.

Trying to figure out how to have cell A1 = sheetname.

I tried the following but got a compile error

y = Sheetname()

Range(A1) = y

Upvotes: 0

Views: 26850

Answers (1)

sam092
sam092

Reputation: 1335

ActiveSheet.Range("A1") = ActiveSheet.Name

If you want it for every sheet, then

Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
    ws.Range("A1") = ws.Name
Next

Upvotes: 1

Related Questions