VBA to insert print headers is dropping words

klb

Well-known Member
Joined
Apr 3, 2002
Messages
821
I am using the following code to insert information in the page header multiple sheets.

Sub Invoice_settings()

Dim INVNO As String
'change color of sheet tab to keep track of which sheets have been assigned invoice number
ActiveSheet.Tab.ColorIndex = 38

INVNO = InputBox(Prompt:="INVOICE NUMBER", _
Title:="ENTER INVOICE NUMBER", Default:=" ")

ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.CenterHeader = "&""Arial,Bold14" & Range("BCI_ADDR").Text
.RightHeader = "&""Arial,Bold14" & Range("INVOICE").Text & INVNO
End With
ActiveWindow.SelectedSheets.PrintPreview
End Sub

The problem I am having is that it is dropping part of the first two words that are contained in the two ranges - BCI_ADDR & INVOICE.

BCI_ADDR is one cell that has the company name and complete address and is formatted with cell wrapping. It wraps to 4 lines
INVOICE contains the Invoice Date and the words "Invoice #" on a wrapped line.

I have many sheets that I need to change the print settings and was hoping to use the above for the headers.

Any suggestiong on what is causing this and, more importantly, how I can get it to work correctly without manually going into each page and editing the headers.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,214,924
Messages
6,122,294
Members
449,077
Latest member
Rkmenon

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