PDA

View Full Version : Solved: Print Settings



nepotist
03-24-2011, 07:24 AM
Hello,

I need help/suggestion with setting the print titles for my workbook. I have uploaded a sample to explain it better.

The row four has the main title and it has a data validation to it. This helps the user to select the type of analysis they wish to use. The table headers get updated based on it to showing the condition selected.

My problem is to get the Main title in center of each page. As per what the current sheet shows it splits in and it not oriented in the center. Also, I have macros depending on the main heading too.

nepotist
03-24-2011, 09:04 AM
I figured out the solution.
Sub PrintReport()
Dim wks As Worksheet
Dim ftr
ftr = ActiveSheet.Range("B4").Value & ActiveSheet.Range("AG4").Value


With ActiveSheet.PageSetup
.CenterHeader = "&24" & ftr
End With
ActiveSheet.Rows("4:4").Hidden = True
ActiveSheet.PrintOut
With ActiveSheet.PageSetup
.CenterHeader = ""
End With
ActiveSheet.Rows("4:4").Hidden = False

End Sub


Thank you

mdmackillop
03-24-2011, 04:43 PM
Whilst wks is really redundant here, use "With WS" (or With ActiveSheet) rather than repeated use of the object
Sub PrintReport()
Dim wks As Worksheet
Dim ftr
Set wks = ActiveSheet
With wks
ftr = .Range("B4").Value & .Range("AG4").Value
.PageSetup.CenterHeader = "&24" & ftr
.Rows("4:4").Hidden = True
.PrintOut
.PageSetup.CenterHeader = ""
.Rows("4:4").Hidden = False
End With
End Sub