Hello,
I am very new to VBA Programing and am still learning my way around things. I know that there is a Type Mismatch error on the Clocksum line but am not sure why. Any tips, pointers, or fixes would be greatly appreciated!
Sub find_problems()
Dim clocknum As Long
Dim ppe As Date
Dim pcode As Long
Dim weeknumber As String
Dim tothrs As Long
Dim clocksum As Long
Dim title1 As String
Dim jobnum As String
Set rclock = range("A2:A10000") 'clock number
Set rppe = range("F2:F10000") 'ppe
Set rhrs = range("Q2:Q10000") 'total hours
Set rweek = range("R2:R10000") 'week
Do While IsEmpty(Selection.Value) = False
clocknum = Selection.Value 'ID Number
ppe = Selection.Offset(0, 5).Value 'Date
pcode = Selection.Offset(0, 8).Value 'Pay Code
tothrs = Selection.Offset(0, 16).Value 'Hours
weeknumber = Selection.Offset(0, 17).Value 'Week Number
title1 = Selection.Offset(0, 3).Value 'Job Title
jobnum = Selection.Offset(0, 6).Value 'Job Number
clocksum = Application.WorksheetFunction.SumProduct((rclock = clocknum) * (rweek = weeknumber) * (rppe = ppe) * (rhrs))
If clocksum > 120 And (Left(title1, 2) = "FF" Or Left(jobnum, 2) = "asst") Then
Selection.EntireRow.Interior.Color = 50000
ElseIf clocksum <= 40 Then
If pcode = 4242 And tothrs = clocksum Then
ActiveCell.Offset(1, 0).range("A1").Select
Else
Selection.EntireRow.Interior.Color = 50000
End If
ElseIf clocksum >= 41 And clocksum <= 72 Then
If pcode = 4242 And tothrs = 40 Then
ActiveCell.Offset(1, 0).range("A1").Select
ElseIf pcode = 4000 And tothrs = clocksum - 40 Then
ActiveCell.Offset(1, 0).range("A1").Select
Else
Selection.EntireRow.Interior.Color = 50000
ActiveCell.Offset(1, 0).range("A1").Select
End If
ElseIf clocksum >= 73 And clocksum <= 84 Then
If pcode = 4242 And tothrs = 40 Then
ActiveCell.Offset(1, 0).range("A1").Select
ElseIf pcode = 4000 And tothrs = clocksum - 40 Then
ActiveCell.Offset(1, 0).range("A1").Select
ElseIf pcode = 8005 And tothrs = clocksum - 72 Then
ActiveCell.Offset(1, 0).range("A1").Select
Else
Selection.EntireRow.Interior.Color = 50000
ActiveCell.Offset(1, 0).range("A1").Select
End If
End If
Loop
End Sub
Bookmarks