You have your internal quote marks messed up. Because
VB uses quote marks to
delineate string constants, it interprets every single quote mark as such a
delimiter. To embed a real quote mark inside a string constant, you must
double them up. This revision to the code line you posted should do what you
want...
Range("E5").Formula =
"=MID(A8,1+FIND(CHAR(1),SUBSTITUTE(A8,""\"",CHAR(1 ),LEN(A8)-LEN(SUBSTITUTE(A8,""\"","""")))),255)"
Notice that I used two adjacent quote marks for each **internal** quote mark
you showed in your posted code line.
Rick
"Steven" wrote in message
...
Why does this not work in my macro?
Range("E5").Formula =
"=MID(A8,1+FIND(CHAR(1),SUBSTITUTE(A8,"\",CHAR(1), LEN(A8)-LEN(SUBSTITUTE(A8,"\","")))),255)"
It works fine when the formula it in the cell.
Thank you,
Steven