Q:

how to use variable containing strings in formula vba

I ask the user input for a string and then need to incorporate this into a formula. I searched on other questions but didn’t get the desired output.
Sname = InputBox("Enter name")

Cells(2, 32).FormulaR1C1 = _
=CONCATENATE(J2,""-"",K2,""-"",L2,""-"" "" & Sname & "" -"",T2,U2,V2,W2,X2,Y2,""-"",AB2,""-"",AC2)

suppose i enter AAA
i want the formula on cell(2,32) to be  
=CONCATENATE(J2,"-",K2,"-",L2,"-" & "AAA" & "-",T2,U2,V2,W2,X2,Y2,"-",AB2,"-",AC2)

A:

Try this:
Cells(2,32).Formula = _
 "=CONCATENATE(J2,""-"",K2,""-"",L2,""-"" & """ & Sname & """ & ""-"",T2,U2,V2,W2,X2,Y2,""-"",AB2,""-"",AC2)"

There was a slight mixup with your quotation marks around the variable.
This one works for me.

