I have a formula (with very long variable names). I replaced the names with VAR1, VAR2 and VAR3 in the sample below for readability. I have tried multiple ways but no able to get it to work
I want the formula to show on multiple line in the vba so that is easier to read.
I have tried multiple variants including
"Line1 _
Line2" there is a space before the _
"Line1 _
& Line2" there is a space before the _
but not working. I get a compilation error after the first row.
my actual code is (with shortened variable names)
I want the formula to show on multiple line in the vba so that is easier to read.
I have tried multiple variants including
"Line1 _
Line2" there is a space before the _
"Line1 _
& Line2" there is a space before the _
but not working. I get a compilation error after the first row.
my actual code is (with shortened variable names)
Code:
ActiveCell.FormulaR1C1 = _
"=IF(AND(LEN(VAR1)=1,LEN(VAR2)=1), _
CONCATENATE(""0"",VAR2,""/0"",VAR1,""/"", _
VAR3), _
IF(AND(LEN(VAR1)=1,LEN(VAR2)=2), _
CONCATENATE(VAR2,""/0"",VAR1,""/"", _
VAR3), _
IF(AND(LEN(VAR1)=2,LEN(VAR2)=1), _
CONCATENATE(""0"",VAR2,""/"",VAR1,""/"", _
VAR3),CONCATENATE(VAR2,""/"", _
VAR3))))"