Print page asking for date range macro

Mike Hughes

Registered User.
Local time
Today, 22:22
Joined
Mar 23, 2002
Messages
493
Would someone please show me how to change this macro to ask the user to put in a start date and an end date before printing? Thanks Mike


Sub Report1()
'
' Report1 Macro
' Macro recorded 7/17/2011 by Mike
'

'
Columns("A:A").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.EntireRow.Hidden = True
ActiveWindow.SmallScroll Down:=-27
Columns("A:M").Select
ActiveSheet.PageSetup.PrintArea = "$A:$M"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ActiveSheet.PageSetup.PrintArea = ""
ActiveSheet.PageSetup.PrintArea = ""
Selection.EntireRow.Hidden = False
End Sub
 
You can either use filters with Inputbox reference to filter between dates.

Sub dates1()
Dim dtm As Date, dtm1 As Date
dtm = InputBox("Please Enter the First Date", "Sample")
dtm1 = InputBox("Please Enter the Second Date", "Sample")
Range("B1").Select
Selection.AutoFilter
ActiveSheet.Range("$B$1:$B$21").AutoFilter Field:=1, Criteria1:= _
">=03/06/2011", Operator:=xlAnd, Criteria2:="<=22/06/2011" 'could be dtm and dtm1 rather than dates

End Sub
 

Users who are viewing this thread

Back
Top Bottom