VBA to format left header specific text

S_SSharma1212

New Member
Joined
Apr 22, 2022
Messages
10
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I wanna change the font and size of the entire left header and make part of that header Bold. Since this doesn't have a cell reference I'm having difficulty trying to figure out how to do this. Advance Thanks for all the answers.
Note that the header info is being fed in using a userform to get the Number and name.

This is what i'm currently getting:
1650948892720.png

This is what i want it to look like:
1650949065390.png
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Are you trying to do this in a cell, or in a userform control like a text box or label?
 
Upvote 0
So the output would actually be in the header. But the input values are from a userform.
Remember that I have no context for what you are doing unless you explain it. Your use of the term "the header" has no meaning to me.
 
Upvote 0
Remember that I have no context for what you are doing unless you explain it. Your use of the term "the header" has no meaning to me.
The page header, that is only visible in the page layout view. I'm trying to update the info in the leftheader of the sheet.
 
Upvote 0
It looks like it should be possible.

VBA Code:
Sub HeaderTest()

    Dim HeaderText As String
    Dim JobNo As String
    Dim CustName As String
    
    JobNo = "1234"
    CustName = "SS"

    HeaderText = "&""-,Bold""Job Number: &""-,Regular""" & JobNo & Chr(10) & "&""-,Bold""Customer: &""-,Regular""" & CustName
    
    With ActiveSheet.PageSetup
        .LeftHeader = HeaderText
    End With
End Sub
 
Upvote 0
Solution
It looks like it should be possible.

VBA Code:
Sub HeaderTest()

    Dim HeaderText As String
    Dim JobNo As String
    Dim CustName As String
   
    JobNo = "1234"
    CustName = "SS"

    HeaderText = "&""-,Bold""Job Number: &""-,Regular""" & JobNo & Chr(10) & "&""-,Bold""Customer: &""-,Regular""" & CustName
   
    With ActiveSheet.PageSetup
        .LeftHeader = HeaderText
    End With
End Sub
Thank You for the help. The bold part is working perfectly now. Would It also be possible to change the font from default to "Cambria"?
 
Upvote 0
I suppose that it would be possible, but you'll need to experiment to determine that. I recommend using the macro recorder to record yourself manually changing the font. Then by inspecting the macro recorder code, you should be able to see how to add that part to your code.
 
Upvote 0
I suppose that it would be possible, but you'll need to experiment to determine that. I recommend using the macro recorder to record yourself manually changing the font. Then by inspecting the macro recorder code, you should be able to see how to add that part to your code.
Thanks for your Help.
 
Upvote 0

Forum statistics

Threads
1,224,826
Messages
6,181,192
Members
453,021
Latest member
pingpong7117

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top