windwardmi
Board Regular
- Joined
- Oct 18, 2009
- Messages
- 138
Hello All,
I am trying to pull rows of info from a specific sheet. The rows I want to pull are for a certain date range in column 1. Creating an employees timesheet for the week.
I started with a recorded Macro and tried to modify the code but got stumped here. The macro I recorded used the filter method for dates between start and end dates.
The following is the code from the original Macro I have created. Any and all comments welcomed. Thank you.
I am trying to pull rows of info from a specific sheet. The rows I want to pull are for a certain date range in column 1. Creating an employees timesheet for the week.
I started with a recorded Macro and tried to modify the code but got stumped here. The macro I recorded used the filter method for dates between start and end dates.
The following is the code from the original Macro I have created. Any and all comments welcomed. Thank you.
Code:
Sub TimeSheet()
'
' TimeSheet Macro
'
' Keyboard Shortcut: Ctrl+t
'
Dim rightsheet As String
Dim startdate As Date
Dim enddate As Date
rightsheet = Application.InputBox("Employee Last Name?")
Sheets(rightsheet).Select
Selection.AutoFilter
startdate = Application.InputBox("Start Date?")
enddate = Application.InputBox("End Date?")
ActiveSheet.Range("$A$1:$P$2").AutoFilter Field:=1, Criteria1:="startdate", _
Operator:=xlAnd, Criteria2:="enddate"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
End Sub