Code:
Sub PrintReport()
'Makes sure that the status bar is visible
Application.DisplayStatusBar = True
'Enter message for status bar
Application.StatusBar = "Generating Report!"
'Turn off Screen updating
Application.ScreenUpdating = False
Dim WS As Worksheet
Dim ReportMonth As String
Dim LHeader As String
ReportMonth = Sheets("Summary").Range("A3").Value
LHeader = Sheets("Comboboxes ").Range("B19").Value
For Each WS In Sheets
'If statement to exclude certain worksheets
If WS.Name <> "Comboboxes" Then
If WS.Name <> "Values" Then
If WS.Name <> "Material" Then
' Enter your message for the statusbar:
Application.StatusBar = "Formatting Report..."
WS.Select
With WS.PageSetup
.LeftHeader = LHeader & Chr(13) & ReportMonth
.CenterHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.CenterHorizontally = True
.CenterVertically = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
Select Case WS.Name
Case Is = "Normal"
WS.PageSetup.RightHeader = "Normal"
Case Is = "Abnormal"
WS.PageSetup.RightHeader = "Abnormal"
Case Is = "Summary"
WS.PageSetup.RightHeader = "Summary"
End Select
' Enter your message for the statusbar:
Application.StatusBar = "Previewing page.."
ActiveWindow.SelectedSheets.PrintPreview
End If
End If
End If
Next WS
'Makes sure that the status bar is invisible
Application.DisplayStatusBar = False
'Turn on Screen updating
Application.ScreenUpdating = True
End Sub
This code works but when it's done running I get an error message box (with the vbCritical sign - looks like a stop sign with an X) and the only message is 400? No text or anything just that number, what's going on?

The StatusBar says "Formatting Report..." so that where it's stuck at, gith? But it's shown me all the sheets (with the exception of the three that I eliminated with the If statements). So it should be done, right? Unless it's still looking for another worksheet?? I've used similiar code before and never had this happen??