Good Morning Experts,
I have used the following in many of the macros I have built, and for some reason, this particular procedure doesn't like my code and I cannot figure out why. This time I've used a different looping method and added multiple variables. I've highlighted the errors I receive below. .Value & .FormulaR1C1 doesn't want to work...
In the past I've always been able to use:
Range("A1").Value = "=(whatever code,1,0)"
and it always just input the formula in my designated range... But not now. Can someone enlighten me please?
I have used the following in many of the macros I have built, and for some reason, this particular procedure doesn't like my code and I cannot figure out why. This time I've used a different looping method and added multiple variables. I've highlighted the errors I receive below. .Value & .FormulaR1C1 doesn't want to work...
In the past I've always been able to use:
Range("A1").Value = "=(whatever code,1,0)"
and it always just input the formula in my designated range... But not now. Can someone enlighten me please?
Code:
Sub Step10a()
ActiveWorkbook.Sheets("HazShipper").Select
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim row As 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
match1 = ""
match2 = ""
match3 = ""
Range("AR").[COLOR=#ff0000][B]Value [/B][/COLOR]= "=VLOOKUP(U2,COMAT!$A$2:$T$50000,16,0)" [COLOR=#008000]'GIVES 1004 ERROR[/COLOR]
Range("AS").[COLOR=#ff0000][B]FormulaR1C1 [/B][/COLOR]= "=VLOOKUP(U2,COMAT!$A$2:$T$50000,17,0)" [COLOR=#008000]'GIVES 1004 ERROR[/COLOR]
Range("AT").FormulaR1C1 = "=VLOOKUP(U2,COMAT!$A$2:$T$50000,18,0)"
Range("AU").FormulaR1C1 = "=VLOOKUP(U2,COMAT!$A$2:$T$50000,19,0)"
Range("AV").FormulaR1C1 = "=VLOOKUP(U2,COMAT!$A$2:$T$50000,20,0)"
Do Until Range("AL" & row).FormulaR1C1 = ""
code1 = Range("AW" & row).Value = "VLOOKUP(C2,IMP.SPL!$A$2:$D$44,2,0)"
code2 = Range("AX" & row).Value = "VLOOKUP(C2,IMP.SPL!$A$2:$D$44,3,0)"
code3 = Range("AY" & row).Value = "VLOOKUP(C2,IMP.SPL!$A$2:$D$44,4,0)"
If code1 = Range("AR" & row).Value Then match1 = "MATCH"
If code1 = Range("AS" & row).Value Then match1 = "MATCH"
If code1 = Range("AT" & row).Value Then match1 = "MATCH"
If code1 = Range("AU" & row).Value Then match1 = "MATCH"
If code1 = Range("AV" & row).Value Then match1 = "MATCH"
If code2 = Range("AR" & row).Value Then match2 = "MATCH"
If code2 = Range("AS" & row).Value Then match2 = "MATCH"
If code2 = Range("AT" & row).Value Then match2 = "MATCH"
If code2 = Range("AU" & row).Value Then match2 = "MATCH"
If code2 = Range("AV" & row).Value Then match2 = "MATCH"
If code3 = Range("AR" & row).Value Then match3 = "MATCH"
If code3 = Range("AS" & row).Value Then match3 = "MATCH"
If code3 = Range("AT" & row).Value Then match3 = "MATCH"
If code3 = Range("AU" & row).Value Then match3 = "MATCH"
If code3 = Range("AV" & row).Value Then match3 = "MATCH"
If match1 = "MATCH" Then
Range("AZ" & row).Value = "MATCHES"
Else
If match2 = "MATCH" Then
Range("AZ" & row).Value = "MATCHES"
Else
If match3 = "MATCH" Then
Range("AZ" & row).Value = "MATCHES"
Else
Range("AZ" & row).Value = "NO MATCHES"
End If
End If
End If
row = row + 1
Loop
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Last edited: