PDA

View Full Version : For each worksheet in active workbook, the name will be shown on ...



clarksonneo
06-14-2011, 01:32 AM
Hi,

I want a macro.

There are 4 worksheets, says sheet a, b, c and d, in my workbook.
For each worksheet in active workbook, the name will be shown on sheet A's column A from row 1.

Eg, the expected result is:
On sheet a,
value in cell A1 is sheet a
value in cell B1 is sheet b
value in cell C1 is sheet c
value in cell D1 is sheet d




could you give write the macro for me?

thanks

mancubus
06-14-2011, 02:00 AM
try:


Sub ws_name()

Dim ws As Worksheet

For Each ws In ActiveWorkbook.Worksheets
For i = 1 To Worksheets.Count
ws.Cells(1, i) = Worksheets(i).Name
Next
Next

End Sub