Hi all,

I wonder if anyone could shed any light on the below.

I would like to construct an IF formula in VBA, so that the formula is displayed in the cell itself and not just the result. Certain results in the IF formula are text and Excel requires that they are enclosed in "". The probelm is, when my formula is displayed on the worksheet, the text responses are not enclosed in "", resulting in a #NAME? error. This will be easier to understand with an example.

My code is:

MyISIN(i, 22) = "=IF(V2=" & "IN" & ",IF(W2-G2=0," & "OK" & "," & "Diff = " & "ROUND(W2-G2,4))," & "N/A" & ")"
In the cell on the worksheet this results in:

Formula: copy to clipboard
=IF(V2=IN,IF(W2-G2=0,OK,Diff = ROUND(W2-G2,4)),N/A)


IN, OK, Diff = and N/A need to be enclosed in "".

What I am after, therefore, is:

Formula: copy to clipboard
=IF(V2="IN",IF(W2-G2=0,"OK","Diff = " & ROUND(W2-G2,4)),"N/A")


I have tried placing extra "" around the text I want as my result, but this does not work.

Thanks in advance,