identify sheet number in header?

S

Steve

I have a workbook with 41 sheets. When printed out each sheet may be more
than one page. However, each sheet is a separate tab in a notebook. So I
wonder if there's a way to set up a header in such a way that the sheet
(i.e., tab) number prints.
 
E

Eduardo

Hi,
In A1 enter this formula it will give the tab name then you will use it in
yours prints
=MID(CELL("filename",C1),FIND("]",CELL("filename",C1))+1,255)
 
S

Steve

I don't want the sheet name. I want the sheet number...1, 2, 3, etc.

Eduardo said:
Hi,
In A1 enter this formula it will give the tab name then you will use it in
yours prints
=MID(CELL("filename",C1),FIND("]",CELL("filename",C1))+1,255)

Steve said:
I have a workbook with 41 sheets. When printed out each sheet may be more
than one page. However, each sheet is a separate tab in a notebook. So I
wonder if there's a way to set up a header in such a way that the sheet
(i.e., tab) number prints.
 
G

Gord Dibben

You want the codename/number of the sheet?

Sub sheetnumber()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Sheets
ws.PageSetup.CenterFooter = ws.CodeName
Next
End Sub


Gord Dibben MS Excel MVP

I don't want the sheet name. I want the sheet number...1, 2, 3, etc.

Eduardo said:
Hi,
In A1 enter this formula it will give the tab name then you will use it in
yours prints
=MID(CELL("filename",C1),FIND("]",CELL("filename",C1))+1,255)

Steve said:
I have a workbook with 41 sheets. When printed out each sheet may be more
than one page. However, each sheet is a separate tab in a notebook. So I
wonder if there's a way to set up a header in such a way that the sheet
(i.e., tab) number prints.
 
S

Steve

That's what I thought I wanted. However, after I created all of the
worksheets I rearranged them. So the codenames aren't sequential. For
example the first sheet in the workbook is actually sheet41. Maybe it's not
possible to do what I want to do. Thanks for trying, though.

Gord Dibben said:
You want the codename/number of the sheet?

Sub sheetnumber()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Sheets
ws.PageSetup.CenterFooter = ws.CodeName
Next
End Sub


Gord Dibben MS Excel MVP

I don't want the sheet name. I want the sheet number...1, 2, 3, etc.

Eduardo said:
Hi,
In A1 enter this formula it will give the tab name then you will use it in
yours prints
=MID(CELL("filename",C1),FIND("]",CELL("filename",C1))+1,255)

:

I have a workbook with 41 sheets. When printed out each sheet may be more
than one page. However, each sheet is a separate tab in a notebook. So I
wonder if there's a way to set up a header in such a way that the sheet
(i.e., tab) number prints.
 
G

Gord Dibben

You want the sheets' position numbers?

Sub sheetnumber()

Dim I As Integer, J As Integer

For I = 1 To Sheets.Count
For J = I To Sheets.Count
Sheets(J).PageSetup.CenterFooter = "sht " & I

Next J
Next I
End Sub


Gord

That's what I thought I wanted. However, after I created all of the
worksheets I rearranged them. So the codenames aren't sequential. For
example the first sheet in the workbook is actually sheet41. Maybe it's not
possible to do what I want to do. Thanks for trying, though.

Gord Dibben said:
You want the codename/number of the sheet?

Sub sheetnumber()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Sheets
ws.PageSetup.CenterFooter = ws.CodeName
Next
End Sub


Gord Dibben MS Excel MVP

I don't want the sheet name. I want the sheet number...1, 2, 3, etc.

:

Hi,
In A1 enter this formula it will give the tab name then you will use it in
yours prints
=MID(CELL("filename",C1),FIND("]",CELL("filename",C1))+1,255)

:

I have a workbook with 41 sheets. When printed out each sheet may be more
than one page. However, each sheet is a separate tab in a notebook. So I
wonder if there's a way to set up a header in such a way that the sheet
(i.e., tab) number prints.
 

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