ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro for Custom Header (https://www.excelbanter.com/excel-discussion-misc-queries/127141-macro-custom-header.html)

Le Jurassien

Macro for Custom Header
 
Hello,

How do I manage to get the macro that I have to display each worksheet name
within the workbook accordingly. Anytime I run the macro in question, the
workbook name displays correctly on each worksheet but the worsheet name does
not match. In fact, it assigns all worksheets the same name (i.e. sheet 1).
Please Help!

Public Sub DoFullPath()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Sheets
With ws.PageSetup
.CenterHeader = ActiveWorkbook.Name & _
vbLf & ActiveSheet.Name

End With
Next ws

End Sub

Thanks,

Earl Kiosterud

Macro for Custom Header
 
Le Jurassien,

ActiveSheet isn't being changed, hence the same name. Try:

.CenterHeader = ActiveWorkbook.Name & _
vbLf & ws.Name

--
Earl Kiosterud
www.smokeylake.com
-----------------------------------------------------------------------
"Le Jurassien" wrote in message
...
Hello,

How do I manage to get the macro that I have to display each worksheet
name
within the workbook accordingly. Anytime I run the macro in question, the
workbook name displays correctly on each worksheet but the worsheet name
does
not match. In fact, it assigns all worksheets the same name (i.e. sheet
1).
Please Help!

Public Sub DoFullPath()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Sheets
With ws.PageSetup
.CenterHeader = ActiveWorkbook.Name & _
vbLf & ActiveSheet.Name

End With
Next ws

End Sub

Thanks,





All times are GMT +1. The time now is 04:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com