W
WLMPilot
Below is the code I am trying to use, but I keep getting a type mismatch
(Runtime Error 13) on the line indicated with "ERROR". The value I am
pulling into date2 is formatted as DATE within the spreadsheet.
What do I need to change?
'Display Estimated Pay on Part-time jobs for current payperiod
Private Sub CommandButton6_Click()
Dim date2, date3 As Date
Dim k, startrow, endrow, gotbrs As Integer
Dim brs, pas As Variant
Dim rng As Range
date3 = Date
Set rng = Worksheets("PT").Range("J8:J58")
startrow = 8
endrow = 58
Loop1:
For k = startrow To endrow Step 2
date2 = rng.Offset(0, 0).Value <=====ERROR
'MsgBox date2
If date3 <= date2 Then
If endrow <= 58 Then
brs = rng.Offset(k - 1, 3).Value
k = endrow
gotbrs = 1
startrow = 67
endrow = 117
rng = Range("J67:J117")
Else
pas = rng.Offset(k - 1, 3).Value
Set k = endrow
End If
End If
Next k
If gotbrs = 1 Then
gotbrs = 0
GoTo Loop1
End If
MsgBox "BRS: " & " brs" & " PAS: " & pas & " TOTAL: " & (brs + pas)
End Sub
Thanks,
Les
(Runtime Error 13) on the line indicated with "ERROR". The value I am
pulling into date2 is formatted as DATE within the spreadsheet.
What do I need to change?
'Display Estimated Pay on Part-time jobs for current payperiod
Private Sub CommandButton6_Click()
Dim date2, date3 As Date
Dim k, startrow, endrow, gotbrs As Integer
Dim brs, pas As Variant
Dim rng As Range
date3 = Date
Set rng = Worksheets("PT").Range("J8:J58")
startrow = 8
endrow = 58
Loop1:
For k = startrow To endrow Step 2
date2 = rng.Offset(0, 0).Value <=====ERROR
'MsgBox date2
If date3 <= date2 Then
If endrow <= 58 Then
brs = rng.Offset(k - 1, 3).Value
k = endrow
gotbrs = 1
startrow = 67
endrow = 117
rng = Range("J67:J117")
Else
pas = rng.Offset(k - 1, 3).Value
Set k = endrow
End If
End If
Next k
If gotbrs = 1 Then
gotbrs = 0
GoTo Loop1
End If
MsgBox "BRS: " & " brs" & " PAS: " & pas & " TOTAL: " & (brs + pas)
End Sub
Thanks,
Les