formula error, vba not liking commas

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to put the following formula into a piece of code (using the
variable 'sFormula' to hold the formula) and get the error message as below,
any ideas how i can get around this. I know i could place it on the
worksheet somewhere and copy it but would like to keep it in code if possible

sFormula="=IF(LEFT(RIGHT(A7,2),1)=",","."&RIGHT(A7,1),"")"

"Compile error expected end of statement"

it appears not to like the first comma in inverted commas

Any ideas will be gratefully received
 
Within string literals, double quotes mus be doubled:
sFormula="=IF(LEFT(RIGHT(A7,2),1)="","","".""&RIGHT(A7,1),"""""")"

HTH
 
sFormula = "=IF(LEFT(RIGHT(A7,2),1)="","","".""&RIGHT(A7,1),"""")"

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
If you don't double up on the quotes, it thinks the first one is the end of
the string and then gets confused by what follows <g>

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
Back
Top