Microsoft Office Tutorials and References
In Depth Information
The Print_Area range lets you set the range of cells using your choice of A1 notation, R1C1
notation, or range names. Examination of the Print_Area range properties will show you the
range in the style that was used to set it.
The following SelectPrint routine allows the user to choose between printing the entire sheet
or just the evening values from the Y2001ByMonth workbook. The Print_Area range is used
to inform Excel what values to print.
Sub SelectPrint()
Dim intReturn As Integer, strPrompt As String, strTitle As String
Dim strRange As String, objName As Name, intCounter As Integer
'Call CreateNames subroutine to ensure properly named ranges
'are available
'Prompt for values to print out
strPrompt = "Click Yes to print only the evenint values " _
& "and click No to print all values."
strTitle = "Microsoft Office Excel 2003 Programming Inside Out"
intReturn = MsgBox(strPrompt, vbYesNoCancel, strTitle)
'Check response from user
Select Case intReturn
Case vbNo 'Print full chart
strRange = "=" & ActiveSheet.Name & "!" & _
ActiveSheet.Name & "AllValues"
Case vbYes 'Print evening times only
strRange = "=" & ActiveSheet.Name & "!" & _
ActiveSheet.Name & "1PM:" & _
ActiveSheet.Name & "8PM"
Case vbCancel 'Cancel completely
Exit Sub
End Select
'Loop through Names collection. Delete Print_Area or
'Print_Titles if found.
intCounter = ActiveSheet.Names.count
While (intCounter > 0)
If ActiveSheet.Names(intCounter).Name = ActiveSheet.Name _
Search JabSto ::

Custom Search