Run-Time Error 13, error 2042

Sphinx404

Board Regular
Joined
May 2, 2015
Messages
186
Office Version
  1. 365
Platform
  1. Windows
I've been through this forum front and back and taking the suggestions from previous posts about this error has given me a lot of knowledge concerning this error, but the error persists nonetheless. Does someone see something I can be doing differently to stop this error from occurring?

Code:
Sub step10()


ActiveWorkbook.Sheets("HazShipper").Select
Application.ScreenUpdating = False
Application.DisplayAlerts = False


Dim row As Long 'CHANGE FROM DOUBLE TO LONG
Dim code1 As String
Dim code2 As String
Dim code3 As String


Dim match1 As String
Dim match2 As String
Dim match3 As String


row = 2


Range("AD2").Formula = "=VLOOKUP(C2,IMP.SPL!$A$2:$D$44,2,0)"
Range("AE2").Formula = "=VLOOKUP(C2,IMP.SPL!$A$2:$D$44,3,0)"
Range("AF2").Formula = "=VLOOKUP(C2,IMP.SPL!$A$2:$D$44,4,0)"


Range("AG2").Formula = "=IFNA(VLOOKUP(U2,COMAT!$A$2:$T$26694,16,0),)"
Range("AH2").Formula = "=IFNA(VLOOKUP(U2,COMAT!$A$2:$T$26694,17,0),)"
Range("AI2").Formula = "=IFNA(VLOOKUP(U2,COMAT!$A$2:$T$26694,18,0),)"
Range("AJ2").Formula = "=IFNA(VLOOKUP(U2,COMAT!$A$2:$T$26694,19,0),)"
Range("AK2").Formula = "=IFNA(VLOOKUP(U2,COMAT!$A$2:$T$26694,20,0),)"


Range("AD2:AK2").Select
Selection.AutoFill Destination:=Range("AD2:AK25000")


Do Until Range("AD" & row).Formula = ""


match1 = ""
match2 = ""
match3 = ""


[B][COLOR=#ff0000]code1 = Range("AD" & row).Value [/COLOR][/B][COLOR=#008000]'code1="RFL" range = error 2042<run-time error="" 13="" type="" mismatch="" -="" hover-over="" code1="RFL" ,="" range="" indicates="" 2042<="" font="">
[COLOR=#008000]'code shuts down when faced with #N/A.... but I have IFNA accounted for in formula..... What gives?[/COLOR]
</run-time>[/COLOR]<run-time error="" 13="" type="" mismatch="" -="" hover-over="" code1="RFL" ,="" range="" indicates="" 2042<="" font="">code2 = Range("AE" & row).Value
code3 = Range("AF" & row).Value


If code1 = Range("AG" & row).Value Then match1 = "MATCH"
If code1 = Range("AH" & row).Value Then match1 = "MATCH"
If code1 = Range("AI" & row).Value Then match1 = "MATCH"
If code1 = Range("AJ" & row).Value Then match1 = "MATCH"
If code1 = Range("AK" & row).Value Then match1 = "MATCH"


If code2 = Range("AG" & row).Value Then match2 = "MATCH"
If code2 = Range("AH" & row).Value Then match2 = "MATCH"
If code2 = Range("AI" & row).Value Then match2 = "MATCH"
If code2 = Range("AJ" & row).Value Then match2 = "MATCH"
If code2 = Range("AK" & row).Value Then match2 = "MATCH"


If code3 = Range("AG" & row).Value Then match3 = "MATCH"
If code3 = Range("AH" & row).Value Then match3 = "MATCH"
If code3 = Range("AI" & row).Value Then match3 = "MATCH"
If code3 = Range("AJ" & row).Value Then match3 = "MATCH"
If code3 = Range("AK" & row).Value Then match3 = "MATCH"


If match1 = "MATCH" Then
    Range("AL" & row).Value = "MATCHES"
Else
    If match2 = "MATCH" Then
        Range("AL" & row).Value = "MATCHES"
    Else
        If match3 = "MATCH" Then
            Range("AL" & row).Value = "MATCHES"
        Else
            Range("AL" & row).Value = "NO MATCHES"
        End If
    End If
End If
row = row + 1


Loop


Application.ScreenUpdating = True
Application.DisplayAlerts = True


End Sub
</run-time>
 
Last edited:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
I don't see anything in the formula in AD2 that accommodates an NA error.
 
Last edited:
Upvote 0
I don't see anything in the formula in AD2 that accommodates an NA error.

As you guys usually are... you are correct. I did not have IFNA added to my first set of formulas, only the second set.
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,215
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top