Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Selecting & formating worksheets

I have a macro to select worksheets in a workbook but it will only format the
active worksheet and not all:
Sub FormatWS
Dim WS As Worksheet

For Each WS In ThisWorkbook.Worksheets
With ActiveSheet.PageSetup
.LeftHeader = ""
....................etc
End With
Next WS
End Sub

Any ideas gratefully received.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Selecting & formating worksheets

For Each WS In ThisWorkbook.Worksheets
With WS.PageSetup
.LeftHeader = ""
....................etc
End With
Next WS
End Sub

--
Regards,
Tom Ogilvy


"Ed123" wrote in message
...
I have a macro to select worksheets in a workbook but it will only format

the
active worksheet and not all:
Sub FormatWS
Dim WS As Worksheet

For Each WS In ThisWorkbook.Worksheets
With ActiveSheet.PageSetup
.LeftHeader = ""
...................etc
End With
Next WS
End Sub

Any ideas gratefully received.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Selecting & formating worksheets

Below is the full macro - as yet I can not get it to work. With WS.PageSetup
has no effect and With activesheet.PageSetup only effects one sheet?

Dim WS As Worksheet

For Each WS In ThisWorkbook.Worksheets ' do something with WS
With WS.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = "&""Arial,Bold""&F"
.CenterFooter = ""
.RightFooter = "&""Arial,Bold""&A"
.LeftMargin = Application.InchesToPoints(0.748031496062992)
.RightMargin = Application.InchesToPoints(0.748031496062992)
.TopMargin = Application.InchesToPoints(0.984251968503937)
.BottomMargin = Application.InchesToPoints(0.984251968503937)
.HeaderMargin = Application.InchesToPoints(0.511811023622047)
.FooterMargin = Application.InchesToPoints(0.511811023622047)
.PrintHeadings = False
.PrintGridlines = True
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
End With
Next WS
End Sub

Kind regards,

Ed.

"Tom Ogilvy" wrote:

For Each WS In ThisWorkbook.Worksheets
With WS.PageSetup
.LeftHeader = ""
....................etc
End With
Next WS
End Sub

--
Regards,
Tom Ogilvy


"Ed123" wrote in message
...
I have a macro to select worksheets in a workbook but it will only format

the
active worksheet and not all:
Sub FormatWS
Dim WS As Worksheet

For Each WS In ThisWorkbook.Worksheets
With ActiveSheet.PageSetup
.LeftHeader = ""
...................etc
End With
Next WS
End Sub

Any ideas gratefully received.





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Selecting & formating worksheets

As expected, it worked fine for me on every sheet. I changed

.CenterFooter = ""

to

.CenterFooter = "TESTMESSAGE"

Just to ensure I had a good visual indicator - and worked like a champ. (as
advised and as expected).

You must not be holding your mouth correctly <g

If you like alot of flash and bang, try:

Sub Tester5()
Dim WS As Worksheet

For Each WS In ThisWorkbook.Worksheets ' do something with WS
WS.Activate
With WS.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = "&""Arial,Bold""&F"
.CenterFooter = "TESTMESSAGE"
.RightFooter = "&""Arial,Bold""&A"
.LeftMargin = Application.InchesToPoints(0.748031496062992)
.RightMargin = Application.InchesToPoints(0.748031496062992)
.TopMargin = Application.InchesToPoints(0.984251968503937)
.BottomMargin = Application.InchesToPoints(0.984251968503937)
.HeaderMargin = Application.InchesToPoints(0.511811023622047)
.FooterMargin = Application.InchesToPoints(0.511811023622047)
.PrintHeadings = False
.PrintGridlines = True
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
End With
WS.PrintPreview
Next WS
End Sub

--
Regards,
Tom Ogilvy



"Ed123" wrote in message
...
Below is the full macro - as yet I can not get it to work. With

WS.PageSetup
has no effect and With activesheet.PageSetup only effects one sheet?

Dim WS As Worksheet

For Each WS In ThisWorkbook.Worksheets ' do something with WS
With WS.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = "&""Arial,Bold""&F"
.CenterFooter = ""
.RightFooter = "&""Arial,Bold""&A"
.LeftMargin = Application.InchesToPoints(0.748031496062992)
.RightMargin = Application.InchesToPoints(0.748031496062992)
.TopMargin = Application.InchesToPoints(0.984251968503937)
.BottomMargin = Application.InchesToPoints(0.984251968503937)
.HeaderMargin = Application.InchesToPoints(0.511811023622047)
.FooterMargin = Application.InchesToPoints(0.511811023622047)
.PrintHeadings = False
.PrintGridlines = True
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
End With
Next WS
End Sub

Kind regards,

Ed.

"Tom Ogilvy" wrote:

For Each WS In ThisWorkbook.Worksheets
With WS.PageSetup
.LeftHeader = ""
....................etc
End With
Next WS
End Sub

--
Regards,
Tom Ogilvy


"Ed123" wrote in message
...
I have a macro to select worksheets in a workbook but it will only

format
the
active worksheet and not all:
Sub FormatWS
Dim WS As Worksheet

For Each WS In ThisWorkbook.Worksheets
With ActiveSheet.PageSetup
.LeftHeader = ""
...................etc
End With
Next WS
End Sub

Any ideas gratefully received.







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
Issue selecting other worksheets SLW612 Excel Discussion (Misc queries) 1 November 14th 08 04:53 PM
Selecting across worksheets JMS Excel Discussion (Misc queries) 1 July 14th 05 10:44 PM
Selecting WorkSheets Jordan Excel Programming 3 February 25th 05 07:10 PM
selecting worksheets Matthew Kramer Excel Programming 1 August 16th 04 10:39 PM
Selecting worksheets without hardcoding Bob Phillips[_6_] Excel Programming 1 May 4th 04 09:01 PM


All times are GMT +1. The time now is 08:40 AM.

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

About Us

"It's about Microsoft Excel"