Trying to figure out why my VLOOKUP won't work in my IF statement, highlighted in RED
Code:
Set mycell = myworksheet.Range("AK" & i) [COLOR=#008000]'Contains Unit of Measure[/COLOR]
Set mycell2 = myworksheet.Range("AD" & i) [COLOR=#008000]'Contains UN/ID#[/COLOR]
Set mycell3 = myworksheet.Range("B" & i) [COLOR=#008000]'Contains static part #[/COLOR]
If mycell.Value = "L" And mycell2.Value = "UN3363" Then [COLOR=#008000]'if UOM is L and UN/ID# is 3363 then[/COLOR]
mycell.Offset(, 2).Formula = "=IFERROR(IF(AL" & i & "=AJ" & i & ",TRUE,FALSE),""Error"")" [COLOR=#008000]'if exact match then true, otherwise false, or error[/COLOR]
Else
mycell.Offset(, 2).Formula = "=IFERROR(IF(ABS(AJ" & i & " - AL" & i & ") <= AL" & i & "*0.1, ""Within Limit"", ""Outside Limit""),""Error"")" [COLOR=#008000]'do this function to see if weight comparison is within limits[/COLOR]
End If
If mycell2.Value = "UN3091" Then
[COLOR=#ff0000] mycell2.Offset(, 9).Formula = "=VLOOKUP([/COLOR][B][COLOR=#b22222]mycell3[/COLOR][/B][COLOR=#ff0000],'UN3091'!$A$2:$D$12,4,0)"[/COLOR]
End If
Next
End Sub
[COLOR=#008000]
[/COLOR]
[COLOR=#008000] 'If mycell2.Value = "UN3091" Then[/COLOR]
[COLOR=#008000] 'vlookup mycell3 from myworksheet and search for it in myworksheet3 (starting in column A)[/COLOR]
[COLOR=#008000] 'when found in myworksheet3 compare the weight (column D) with the weight in myworksheet (column AL)[/COLOR]
[COLOR=#008000] 'if weights match, then RETURN true, otherwise false - (RETURNs in myworksheet column AM & i)[/COLOR]
[COLOR=#008000] '***possible formula soultion??[/COLOR]
[COLOR=#008000] '=IF(AD32="UN3091",VLOOKUP(B32,'UN3091'!$A$2:$D$12,4,FALSE),"")[/COLOR]