Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
FJ FJ is offline
external usenet poster
 
Posts: 90
Default Change font size of header on every sheet?

Hi, I have several workbooks with over 50 worksheets. I have to change the
font size of the text in the headers to 14 points on every sheet. Is there a
quick way to do this with VBA? I tried doing it without VBA, by selecting
all the sheets at once and changing the font size, but of course this also
changed the text and made it the same as the text in the first sheet header.

Thanks in advance for any information.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Change font size of header on every sheet?

The may be other formating besides Font size in your header. for eample

$D&10MyHeader &10 is font size 10

there are two fromats in the header. You have to strip out the 2nd
formating and replace with &14. Try this code


Sub Fix_Headers()
'
' Macro1 Macro
' Macro recorded 5/12/2008 by jwarburg
'

'
For Each sht In ThisWorkbook.Sheets
With ActiveSheet.PageSetup
.LeftHeader = fixfont(.LeftHeader)
.CenterHeader = fixfont(.CenterHeader)
.RightHeader = fixfont(.RightHeader)
End With
Next sht
End Sub
Function fixfont(header)

fixfont = ""
Do While InStr(header, "&") 0
If IsNumeric(Mid(header, 2, 1)) Then
'character after amphersand is a number
'check if the old font size is one or two digits
If IsNumeric(Mid(header, 3, 1)) Then
'old font is 2 digits
'remove old font size
header = Mid(header, 4)
Else
'old font is 1 digits
'remove old font size
header = Mid(header, 3)
End If
fixfont = fixfont & "&14" & header
header = ""
Else
'remove amphersand other formats
If InStr(2, header, "&") 0 Then
'remove first format string
fixfont = Left(header, InStr(2, header, "&") - 1)
header = Mid(header, InStr(2, header, "&"))
Else
'there are no more amphersand, add font
fixfont = fixfont & "&14" & header
End If
End If
Loop

End Function


"FJ" wrote:

Hi, I have several workbooks with over 50 worksheets. I have to change the
font size of the text in the headers to 14 points on every sheet. Is there a
quick way to do this with VBA? I tried doing it without VBA, by selecting
all the sheets at once and changing the font size, but of course this also
changed the text and made it the same as the text in the first sheet header.

Thanks in advance for any information.

  #3   Report Post  
Posted to microsoft.public.excel.programming
FJ FJ is offline
external usenet poster
 
Posts: 90
Default Change font size of header on every sheet?

Hi, Joel, thanks for your response. I tried your code and it worked for the
first worksheet but it didn't seem to change the font size for any of the
others.




"Joel" wrote:

The may be other formating besides Font size in your header. for eample

$D&10MyHeader &10 is font size 10

there are two fromats in the header. You have to strip out the 2nd
formating and replace with &14. Try this code


Sub Fix_Headers()
'
' Macro1 Macro
' Macro recorded 5/12/2008 by jwarburg
'

'
For Each sht In ThisWorkbook.Sheets
With ActiveSheet.PageSetup
.LeftHeader = fixfont(.LeftHeader)
.CenterHeader = fixfont(.CenterHeader)
.RightHeader = fixfont(.RightHeader)
End With
Next sht
End Sub
Function fixfont(header)

fixfont = ""
Do While InStr(header, "&") 0
If IsNumeric(Mid(header, 2, 1)) Then
'character after amphersand is a number
'check if the old font size is one or two digits
If IsNumeric(Mid(header, 3, 1)) Then
'old font is 2 digits
'remove old font size
header = Mid(header, 4)
Else
'old font is 1 digits
'remove old font size
header = Mid(header, 3)
End If
fixfont = fixfont & "&14" & header
header = ""
Else
'remove amphersand other formats
If InStr(2, header, "&") 0 Then
'remove first format string
fixfont = Left(header, InStr(2, header, "&") - 1)
header = Mid(header, InStr(2, header, "&"))
Else
'there are no more amphersand, add font
fixfont = fixfont & "&14" & header
End If
End If
Loop

End Function


"FJ" wrote:

Hi, I have several workbooks with over 50 worksheets. I have to change the
font size of the text in the headers to 14 points on every sheet. Is there a
quick way to do this with VBA? I tried doing it without VBA, by selecting
all the sheets at once and changing the font size, but of course this also
changed the text and made it the same as the text in the first sheet header.

Thanks in advance for any information.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Change font size of header on every sheet?

from
With ActiveSheet.PageSetup
to
With sht.PageSetup

"FJ" wrote:

Hi, Joel, thanks for your response. I tried your code and it worked for the
first worksheet but it didn't seem to change the font size for any of the
others.




"Joel" wrote:

The may be other formating besides Font size in your header. for eample

$D&10MyHeader &10 is font size 10

there are two fromats in the header. You have to strip out the 2nd
formating and replace with &14. Try this code


Sub Fix_Headers()
'
' Macro1 Macro
' Macro recorded 5/12/2008 by jwarburg
'

'
For Each sht In ThisWorkbook.Sheets
With ActiveSheet.PageSetup
.LeftHeader = fixfont(.LeftHeader)
.CenterHeader = fixfont(.CenterHeader)
.RightHeader = fixfont(.RightHeader)
End With
Next sht
End Sub
Function fixfont(header)

fixfont = ""
Do While InStr(header, "&") 0
If IsNumeric(Mid(header, 2, 1)) Then
'character after amphersand is a number
'check if the old font size is one or two digits
If IsNumeric(Mid(header, 3, 1)) Then
'old font is 2 digits
'remove old font size
header = Mid(header, 4)
Else
'old font is 1 digits
'remove old font size
header = Mid(header, 3)
End If
fixfont = fixfont & "&14" & header
header = ""
Else
'remove amphersand other formats
If InStr(2, header, "&") 0 Then
'remove first format string
fixfont = Left(header, InStr(2, header, "&") - 1)
header = Mid(header, InStr(2, header, "&"))
Else
'there are no more amphersand, add font
fixfont = fixfont & "&14" & header
End If
End If
Loop

End Function


"FJ" wrote:

Hi, I have several workbooks with over 50 worksheets. I have to change the
font size of the text in the headers to 14 points on every sheet. Is there a
quick way to do this with VBA? I tried doing it without VBA, by selecting
all the sheets at once and changing the font size, but of course this also
changed the text and made it the same as the text in the first sheet header.

Thanks in advance for any information.

  #5   Report Post  
Posted to microsoft.public.excel.programming
FJ FJ is offline
external usenet poster
 
Posts: 90
Default Change font size of header on every sheet?

Hi, Joel, it worked! Thank you so much! :) You have just saved me so much
work!

Thanks again! :)




"Joel" wrote:

from
With ActiveSheet.PageSetup
to
With sht.PageSetup

"FJ" wrote:

Hi, Joel, thanks for your response. I tried your code and it worked for the
first worksheet but it didn't seem to change the font size for any of the
others.




"Joel" wrote:

The may be other formating besides Font size in your header. for eample

$D&10MyHeader &10 is font size 10

there are two fromats in the header. You have to strip out the 2nd
formating and replace with &14. Try this code


Sub Fix_Headers()
'
' Macro1 Macro
' Macro recorded 5/12/2008 by jwarburg
'

'
For Each sht In ThisWorkbook.Sheets
With ActiveSheet.PageSetup
.LeftHeader = fixfont(.LeftHeader)
.CenterHeader = fixfont(.CenterHeader)
.RightHeader = fixfont(.RightHeader)
End With
Next sht
End Sub
Function fixfont(header)

fixfont = ""
Do While InStr(header, "&") 0
If IsNumeric(Mid(header, 2, 1)) Then
'character after amphersand is a number
'check if the old font size is one or two digits
If IsNumeric(Mid(header, 3, 1)) Then
'old font is 2 digits
'remove old font size
header = Mid(header, 4)
Else
'old font is 1 digits
'remove old font size
header = Mid(header, 3)
End If
fixfont = fixfont & "&14" & header
header = ""
Else
'remove amphersand other formats
If InStr(2, header, "&") 0 Then
'remove first format string
fixfont = Left(header, InStr(2, header, "&") - 1)
header = Mid(header, InStr(2, header, "&"))
Else
'there are no more amphersand, add font
fixfont = fixfont & "&14" & header
End If
End If
Loop

End Function


"FJ" wrote:

Hi, I have several workbooks with over 50 worksheets. I have to change the
font size of the text in the headers to 14 points on every sheet. Is there a
quick way to do this with VBA? I tried doing it without VBA, by selecting
all the sheets at once and changing the font size, but of course this also
changed the text and made it the same as the text in the first sheet header.

Thanks in advance for any information.

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
I'm unable to change font size on a excell sheet Steve Excel Worksheet Functions 1 January 3rd 10 06:03 PM
How do I change the font size inside a sheet tab? rgranell Excel Worksheet Functions 2 December 16th 08 07:15 PM
How can I change the font size on an Excel sheet tab? Inobugs Excel Discussion (Misc queries) 3 October 26th 05 10:58 AM
Change font size on sheet tabs Gavin Excel Discussion (Misc queries) 1 June 13th 05 07:50 AM
Change Header Font Size Bret Excel Programming 2 October 27th 04 04:19 PM


All times are GMT +1. The time now is 06:50 PM.

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"