windwardmi
Board Regular
- Joined
- Oct 18, 2009
- Messages
- 138
I am using the below code to pull rows meeting a certain date criteria. The rows contain columns that I need to sum. Example: No. of regular hours and overtime hours.
How can I add a row after the right rows are pulled with the sum() formula in the column where I need it?
How can I add a row after the right rows are pulled with the sum() formula in the column where I need it?
Code:
Sub TimeSheet()
'
' TimeSheet Macro
'
' Keyboard Shortcut: Ctrl+t
'
Dim WS As Worksheet
Dim rightsheet As String
Dim StartDate As Date, EndDate As Date
StartDate = Application.InputBox("Start Date?")
EndDate = Application.InputBox("End Date?")
'ActiveSheet.PageSetup.CenterHeader = "&12" & rightsheet & Chr(10) & ActiveSheet.Name & Chr(13) & rightsheet & Chr(10) & (StartDate) & " To " & (EndDate)
ActiveSheet.PageSetup.RightHeader = "&12" & Chr(13) & rightsheet & Chr(10) & (StartDate) & " To " & (EndDate)
rightsheet = Application.InputBox("Employee Last Name?")
Sheets(rightsheet).Select
Selection.AutoFilter
ActiveSheet.Range("$A$1").CurrentRegion.AutoFilter Field:=1, Criteria1:=">=" & CLng(StartDate), _
Operator:=xlAnd, Criteria2:="<=" & CLng(EndDate)
'ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
'IgnorePrintAreas:=False
End Sub