Excel 2010 VBA adding random vertical page breaks when header is edited - Urgent, Please Help!

JeffK627

Active Member
Joined
Jun 22, 2005
Messages
313
I have an Excel 2010 workbook that creates another workbook and copies some data to it. Everything works fine until I create the Header, at which point vertical page breaks are inserted every few columns of the new workbook. It's not a consistent number of columns in between the breaks. I can't remove them with VBA or even by manually clicking "Reset All Page Breaks".

There are NO page breaks in the workbook that creates the new workbook, so they aren't being copied. They don't appear until the Header is created.

I'm at my wits end, this is due in a couple of days and I can't finish without solving this. Here's the code that creates the header (I've deleted some confidential information but it's just literal strings so it shouldn't matter):

Code:
Function DoManifestHeader(wb As Workbook)
'Creates and populates Header for Manifest
    Dim sLeftHeader As String
    Dim sCenterHeader As String
    Dim sRightHeader As String
    Dim sSponsor As String
    Dim sProtocol As String
    Dim sStudyNumber As String
    Dim sSpecimenType As String
    Dim sPMName As String
    Dim sPMPhone As String
    Dim ws As Worksheet, wsInfo As Worksheet
    
    Set ws = wb.Worksheets("Shipping Manifest")
    Set wsInfo = wb.Worksheets("Information")
    
    sSponsor = wsInfo.Range("C2").Value
    sProtocol = wsInfo.Range("C4").Value
    sStudyNumber = wsInfo.Range("C5").Value
    sSpecimenType = wsInfo.Range("C9").Value
    sPMName = wsInfo.Range("C6").Value
    sPMPhone = wsInfo.Range("C7").Value
    
    sLeftHeader = "Company Name" & vbCr _
                    & "Address" & vbCr _
                    & "City, State Zip" & vbCr _
                    & "Phone"
    sCenterHeader = "Sponsor: " & sSponsor & vbCr _
                    & "Protocol: " & sProtocol & vbCr _
                    & "Study Number: " & sStudyNumber & vbCr _
                    & "Specimen Type: " & sSpecimenType & vbCr _
                    & "Project Manager: " & sPMName & vbCr _
                    & "PM Phone: " & sPMPhone
    sRightHeader = "&F"
    
    With ws.PageSetup
        .LeftHeader = sLeftHeader
        .CenterHeader = sCenterHeader
        .RightHeader = sRightHeader
    End With
End Function

Any help appreciated!
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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