Creating Column headers from Worksheet Names

  • Thread starter Thread starter Mctabish
  • Start date Start date
M

Mctabish

I am trying to create a workbook that has weekly data in a different
worksheet.
I want to have the first page tally and report data from all of the other
sheets. So.... I need to first count the number of sheets, then, to get the
name of each worksheet that is greater than 1, and put that name into the
column based on COLUMN() So, worksheet2 name would be the column header for
Column2, etc....

Thanks!
Mc
 
You can use a macro that will populate that row with the name of the worksheets.

But it might be simpler to put all your data on one worksheet--and add an
indicator (per row) that would keep track of which "group" that row should be
in.

Option Explicit
Sub testme()
Dim wCtr As Long
With ActiveWorkbook
For wCtr = 2 To .Worksheets.Count
.Worksheets(1).Cells(1, wCtr).Value = "'" & .Worksheets(wCtr).Name
Next wCtr
End With
End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 

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

Back
Top