windwardmi
Board Regular
- Joined
- Oct 18, 2009
- Messages
- 138
I have the following VBA code that works most of the way:
This part of the code does not work. Why is that? It works by itself in a separate procedure. What am I missing.
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
ActiveSheet.Range("$A$1").CurrentRegion.AutoFilter Field:=1, Criteria1:=">=" & CLng(StartDate), _
Operator:=xlAnd, Criteria2:="<=" & CLng(EndDate)
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
ActiveSheet.Range("$A$1").CurrentRegion.AutoFilter Field:=1, Criteria1:=">=" & CLng(StartDate), _
Operator:=xlAnd, Criteria2:="<=" & CLng(EndDate)
Range("E65536").End(xlUp).Offset(2, 0).Value = "TOTAL"
Range("I65536").End(xlUp).Offset(2, 0).Value = _
WorksheetFunction.Sum(Range("I2:I" & Cells.SpecialCells(xlLastCell).Row))
Range("j65536").End(xlUp).Offset(2, 0).Value = _
WorksheetFunction.Sum(Range("j2:j" & Cells.SpecialCells(xlLastCell).Row))
'ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
'IgnorePrintAreas:=False
End Sub
This part of the code does not work. Why is that? It works by itself in a separate procedure. What am I missing.
Code:
Range("E65536").End(xlUp).Offset(2, 0).Value = "TOTAL"
Range("I65536").End(xlUp).Offset(2, 0).Value = _
WorksheetFunction.Sum(Range("I2:I" & Cells.SpecialCells(xlLastCell).Row))
Range("j65536").End(xlUp).Offset(2, 0).Value = _
WorksheetFunction.Sum(Range("j2:j" & Cells.SpecialCells(xlLastCell).Row))