Trouble Adding in 3rd Variable for IF Statement VLOOKUP

Sphinx404

Board Regular
Joined
May 2, 2015
Messages
186
Office Version
  1. 365
Platform
  1. Windows
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]
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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