Results 1 to 10 of 10

Type Mismatch Error

Threaded View

  1. #1
    Registered User
    Join Date
    12-15-2010
    Location
    Greenville, South Carolina
    MS-Off Ver
    Excel 2007
    Posts
    60

    Talking Type Mismatch Error

    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
    Last edited by Decoderman; 04-19-2011 at 12:27 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1