I am constructing a formula programatically. The formula contains double quotes (for the TEXT function) which I am escapeing with the chr value for double quotes.
The build of the formula is this:
Dim Man_Ed_Formula As String
Man_Ed_Formula = "=DATEVALUE(TEXT(Employees!H2," & Chr(34) & "dd/mm/yyyy" & Chr(34) & "))"
So the formula should look like this:
=DATEVALUE(TEXT(Employees!H2,"dd/mm/yyyy"))
The code I use to apply the formula is this:
Range("B2").Offset(loopcounter, 0).Range("A1").FormulaR1C1 = Man_Ed_Formula
The string containing the formula(Man_Ed_Formula) looks fine before applying it, but it ends up putting single quotes around the H2, so the formula end up looking like this
=DATEVALUE(TEXT(Employees!'H2',"dd/mm/yyyy"))
This is invalid and I can't figure out why it is inserting the stray apostrophes.
Thanks
The risk with keeping an open mind is having your brains fall out.
Shaunk
The build of the formula is this:
Dim Man_Ed_Formula As String
Man_Ed_Formula = "=DATEVALUE(TEXT(Employees!H2," & Chr(34) & "dd/mm/yyyy" & Chr(34) & "))"
So the formula should look like this:
=DATEVALUE(TEXT(Employees!H2,"dd/mm/yyyy"))
The code I use to apply the formula is this:
Range("B2").Offset(loopcounter, 0).Range("A1").FormulaR1C1 = Man_Ed_Formula
The string containing the formula(Man_Ed_Formula) looks fine before applying it, but it ends up putting single quotes around the H2, so the formula end up looking like this
=DATEVALUE(TEXT(Employees!'H2',"dd/mm/yyyy"))
This is invalid and I can't figure out why it is inserting the stray apostrophes.
Thanks
The risk with keeping an open mind is having your brains fall out.
Shaunk