Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default select all sheets?

I have a small macro that reworks the headers and footers in Excel.
But it works only on the active sheet.

What code can I put before it to "select all sheets" in the workbook?

Thanx,
- Mike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default select all sheets?

no need to select.

Dim sht As Worksheet
For Each sht In ActiveWorkbook.Worksheets
sht.PageSetup.LeftHeader = "HEADER TEXT")
Next sht

"MikeF" wrote:

I have a small macro that reworks the headers and footers in Excel.
But it works only on the active sheet.

What code can I put before it to "select all sheets" in the workbook?

Thanx,
- Mike

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default select all sheets?

Thanx Spencer.
I am actually using 4 of the six available headers/footers on each page.
What's the best "with/endwith" stmt to use in conjunction with your code?

- Mike


"Spencer" wrote:

no need to select.

Dim sht As Worksheet
For Each sht In ActiveWorkbook.Worksheets
sht.PageSetup.LeftHeader = "HEADER TEXT")
Next sht

"MikeF" wrote:

I have a small macro that reworks the headers and footers in Excel.
But it works only on the active sheet.

What code can I put before it to "select all sheets" in the workbook?

Thanx,
- Mike

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default select all sheets?

For some additional functionality, if you have a range named "LeftHeader"
you can insert this statement and make the left header a reference to a cell
range's text instead of "hard coding" it.

Dim sht As Worksheet
Dim lftHdrRng As String

lftHdrRng = Range("LeftHeader").Text

For Each sht In ActiveWorkbook.Worksheets
With sht.PageSetup
.LeftHeader = lftHdrRng
.CenterHeader = "CENTER HEADER TEXT"
.RightHeader = "RIGHT HEADER TEXT"
.LeftFooter = "LEFT FOOTER TEXT"
.CenterFooter = "CENTER FOOTER TEXT"
.RightFooter = "RIGHT FOOTER TEXT"
End With
Next sht




"MikeF" wrote:

Thanx Spencer.
I am actually using 4 of the six available headers/footers on each page.
What's the best "with/endwith" stmt to use in conjunction with your code?

- Mike


"Spencer" wrote:

no need to select.

Dim sht As Worksheet
For Each sht In ActiveWorkbook.Worksheets
sht.PageSetup.LeftHeader = "HEADER TEXT")
Next sht

"MikeF" wrote:

I have a small macro that reworks the headers and footers in Excel.
But it works only on the active sheet.

What code can I put before it to "select all sheets" in the workbook?

Thanx,
- Mike

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default select all sheets?


Looks great, thank you.

"Spencer" wrote:

For some additional functionality, if you have a range named "LeftHeader"
you can insert this statement and make the left header a reference to a cell
range's text instead of "hard coding" it.

Dim sht As Worksheet
Dim lftHdrRng As String

lftHdrRng = Range("LeftHeader").Text

For Each sht In ActiveWorkbook.Worksheets
With sht.PageSetup
.LeftHeader = lftHdrRng
.CenterHeader = "CENTER HEADER TEXT"
.RightHeader = "RIGHT HEADER TEXT"
.LeftFooter = "LEFT FOOTER TEXT"
.CenterFooter = "CENTER FOOTER TEXT"
.RightFooter = "RIGHT FOOTER TEXT"
End With
Next sht




"MikeF" wrote:

Thanx Spencer.
I am actually using 4 of the six available headers/footers on each page.
What's the best "with/endwith" stmt to use in conjunction with your code?

- Mike


"Spencer" wrote:

no need to select.

Dim sht As Worksheet
For Each sht In ActiveWorkbook.Worksheets
sht.PageSetup.LeftHeader = "HEADER TEXT")
Next sht

"MikeF" wrote:

I have a small macro that reworks the headers and footers in Excel.
But it works only on the active sheet.

What code can I put before it to "select all sheets" in the workbook?

Thanx,
- Mike



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default select all sheets?

You've been extremely helpful.
Although I've just ran into a kink -- instead of select ALL sheets, will
need to run the subroutine only on SELECTED sheets.
Any ideas?
Thanx in advance.
- Mike

"Spencer" wrote:

For some additional functionality, if you have a range named "LeftHeader"
you can insert this statement and make the left header a reference to a cell
range's text instead of "hard coding" it.

Dim sht As Worksheet
Dim lftHdrRng As String

lftHdrRng = Range("LeftHeader").Text

For Each sht In ActiveWorkbook.Worksheets
With sht.PageSetup
.LeftHeader = lftHdrRng
.CenterHeader = "CENTER HEADER TEXT"
.RightHeader = "RIGHT HEADER TEXT"
.LeftFooter = "LEFT FOOTER TEXT"
.CenterFooter = "CENTER FOOTER TEXT"
.RightFooter = "RIGHT FOOTER TEXT"
End With
Next sht




"MikeF" wrote:

Thanx Spencer.
I am actually using 4 of the six available headers/footers on each page.
What's the best "with/endwith" stmt to use in conjunction with your code?

- Mike


"Spencer" wrote:

no need to select.

Dim sht As Worksheet
For Each sht In ActiveWorkbook.Worksheets
sht.PageSetup.LeftHeader = "HEADER TEXT")
Next sht

"MikeF" wrote:

I have a small macro that reworks the headers and footers in Excel.
But it works only on the active sheet.

What code can I put before it to "select all sheets" in the workbook?

Thanx,
- Mike

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default select all sheets?

For Each sht In ActiveWindow.SelectedSheets


Gord Dibben MS Excel MVP


On Wed, 7 Mar 2007 14:14:03 -0800, MikeF
wrote:

You've been extremely helpful.
Although I've just ran into a kink -- instead of select ALL sheets, will
need to run the subroutine only on SELECTED sheets.
Any ideas?
Thanx in advance.
- Mike

"Spencer" wrote:

For some additional functionality, if you have a range named "LeftHeader"
you can insert this statement and make the left header a reference to a cell
range's text instead of "hard coding" it.

Dim sht As Worksheet
Dim lftHdrRng As String

lftHdrRng = Range("LeftHeader").Text

For Each sht In ActiveWorkbook.Worksheets
With sht.PageSetup
.LeftHeader = lftHdrRng
.CenterHeader = "CENTER HEADER TEXT"
.RightHeader = "RIGHT HEADER TEXT"
.LeftFooter = "LEFT FOOTER TEXT"
.CenterFooter = "CENTER FOOTER TEXT"
.RightFooter = "RIGHT FOOTER TEXT"
End With
Next sht




"MikeF" wrote:

Thanx Spencer.
I am actually using 4 of the six available headers/footers on each page.
What's the best "with/endwith" stmt to use in conjunction with your code?

- Mike


"Spencer" wrote:

no need to select.

Dim sht As Worksheet
For Each sht In ActiveWorkbook.Worksheets
sht.PageSetup.LeftHeader = "HEADER TEXT")
Next sht

"MikeF" wrote:

I have a small macro that reworks the headers and footers in Excel.
But it works only on the active sheet.

What code can I put before it to "select all sheets" in the workbook?

Thanx,
- Mike


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select the same cell in sheets 2 & sheets 3 Oggy Excel Programming 0 January 8th 07 08:02 PM
How to Select All sheets Dawn Bjork Buzbee Excel Programming 2 April 26th 06 12:20 AM
Select first 3 sheets StephanieH Excel Programming 5 December 30th 05 04:59 PM
sheets.select kurt Excel Programming 2 November 28th 05 04:34 PM
select sheets by name - how? Walt[_2_] Excel Programming 5 July 30th 03 10:42 PM


All times are GMT +1. The time now is 09:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"