Results 1 to 11 of 11

Type MisMatch error (13) with if statement using loop

Threaded View

mdnghtsnpr Type MisMatch error (13) with... 04-23-2010, 05:34 PM
davegugg Re: Type MisMatch error (13)... 04-23-2010, 05:44 PM
mdnghtsnpr Re: Type MisMatch error (13)... 04-23-2010, 05:55 PM
davegugg Re: Type MisMatch error (13)... 04-23-2010, 05:59 PM
mdnghtsnpr Re: Type MisMatch error (13)... 04-23-2010, 06:07 PM
davegugg Re: Type MisMatch error (13)... 04-23-2010, 05:54 PM
davegugg Re: Type MisMatch error (13)... 04-23-2010, 06:10 PM
mdnghtsnpr Re: Type MisMatch error (13)... 04-23-2010, 06:15 PM
davegugg Re: Type MisMatch error (13)... 04-23-2010, 06:43 PM
protonLeah Re: Type MisMatch error (13)... 04-23-2010, 06:46 PM
mdnghtsnpr Re: Type MisMatch error (13)... 04-26-2010, 10:37 AM
  1. #1
    Registered User
    Join Date
    04-23-2010
    Location
    Albuquerque, USA
    MS-Off Ver
    Excel 2007
    Posts
    21

    Talking Type MisMatch error (13) with if statement using loop

    I am having a problem with this code,

    Private Sub CommandButton4_Click()
        Dim DesCount As Integer
        Dim DesCount2 As Integer
        Dim DesCount3 As Integer
        Dim DesFile As String
        Dim Bs As String
    
    
    DesFile = ActiveWorkbook.Name
    DesCount = Application.WorksheetFunction.CountA(Workbooks(DesFile).Sheets("Invoice").Range("A:A"))
    DesCount2 = Application.WorksheetFunction.CountA(Workbooks(DesFile).Sheets("Paid").Range("A:A"))
    DesCount3 = Application.WorksheetFunction.CountA(Workbooks(DesFile).Sheets("DCN-Log").Range("C:C"))
    
    For a = 2 To DesCount
    For b = 2 To DesCount2
    
    If Workbooks(DesFile).Sheets("Invoice").Range("A" + a).Value = Workbooks(DesFile).Sheets("Paid").Range("A" + b).Value Then Call Update_Cell(DesFile, "A", a)
    
    Next b
    
    
    
    
    For c = 2 To DesCount3
    If Workbooks(DesFile).Sheets("Invoice").Range("A" + a).Value = Workbooks(DesFile).Sheets("DCN-Log").Range("C" + c).Value Then Call Update_Cell2(DesFile, "A", a) Else Call Update_Cell3(DesFile, "A", a)
    
    If Workbooks(DesFile).Sheets("Invoice").Range("B" + a).Value = Workbooks(DesFile).Sheets("DCN-Log").Range("B" + c).Value Then Call Update_Cell2(DesFile, "A", a) Else Call Update_Cell3(DesFile, "A", a)
    
    If Workbooks(DesFile).Sheets("Invoice").Range("C" + a).Value = Workbooks(DesFile).Sheets("DCN-Log").Range("F" + c).Value Then Call Update_Cell2(DesFile, "A", a) Else Call Update_Cell3(DesFile, "A", a)
    
    If Workbooks(DesFile).Sheets("Invoice").Range("L" + a).Value = Workbooks(DesFile).Sheets("DCN-Log").Range("K" + c).Value Then Call Update_Cell2(DesFile, "A", a) Else Call Update_Cell3(DesFile, "A", a)
    
    If Workbooks(DesFile).Sheets("Invoice").Range("F" + a).Value = Workbooks(DesFile).Sheets("DCN-Log").Range("O" + c).Value Then Call Update_Cell2(DesFile, "A", a) Else Call Update_Cell3(DesFile, "A", a)
    
    Next c
    Next a
    
    End Sub
    The macro will not run this IF loop which calls a macro to highlight a cell if the values match. I get a type mismatch error when it comes to the veritable. If the range is changed to a set value the macro works but I can't figure out why this error is occurring. Could someone help me with this?
    Last edited by mdnghtsnpr; 04-26-2010 at 10:37 AM.

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