Hello everyone,

I created a Lambda function that works perfectly for me,
=LAMBDA(x,y, IF(x="oz",MATCH(y,ConversionTable[OZ],1),IF(x="ml",MATCH(y,ConversionTable[ML],1),IF(x="tsp",MATCH(y,ConversionTable[TSP],1),IF(x="tbsp",MATCH(y,ConversionTable[TBSP],1),IF(x="cup",MATCH(y,ConversionTable[CUPS],1),IF(x="l",MATCH(y,ConversionTable[L],1))))))))
I assigned this function in name manager called "Conversion".

if I manually enter the following in a cell H16 for instance, the formula works perfectly and I get the result I need.
(H16 is part of a table, so that is why you see column references in the code)
(Also, ConversionTable is just another table created to fine the result I need)

=ROUND(IF([@Units]="g",[@RecipeCallsFor],INDEX(ConversionTable,MATCH(Conversion(G16,F16),ConversionTable[Row],0),2)),0)
I am now trying to enter this exact same code, in cell H17, using the following VBA code,
    Range("H17").Formula2 = "=ROUND(IF([@Units]=""g"",[@RecipeCallsFor],INDEX(ConversionTable,MATCH(Conversion(G16,F16),ConversionTable[Row],0),2)),0)"
The problem I am having is with the '(Conversion(G16,F16)' portion. the G16 and F16 need to represent the current row I am working on, in this case 17. But they stay consistent at G16 and F16.

I tried changing the G16 to "range("G" & selection.row).value)' and did the same thing for the F16

So my VBA Code looks like this,
Range("H" & Selection.Row).Formula2 = "=ROUND(IF([@Units]=""g"",[@RecipeCallsFor],INDEX(ConversionTable,MATCH(Conversion(range("G" & selection.row).value,range("F" & selection.row).value),ConversionTable[Row],0),2)),0)"
how ever I instantly get a compile error, expected end of statement and the "G" in 'range("G" & selection.row).value' is highlighted.

I hope all this makes sense, I tried to be as detail as I could.
Does anyone know how to insert a lambda function using VBA where the variable(s) needed are dynamic and are base on the current row you are working on.