Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Formula = problem

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default Formula = problem

You have a missing left parentheses and an extraneous dash in there.

Try recording the entry of the formula - you'll get something like
this...

Range("e5").FormulaR1C1 = _
"=MID(R[7]C,
1+FIND(CHAR(1),SUBSTITUTE(R[7]C,""\"",CHAR(1),LEN(R[7]C)-
LEN(SUBSTITUTE(R[7]C,""\"","""")))),255)"

Cliff Edwards
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Formula = problem

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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default Formula = problem

Hmmm - when I copied the formula out of your post there was a missing
left parentheses and an extra dash once pasted into a cell... weird -
but looking at it now, it looks ok. Anyway, watch the wrap in my
reply.

Cliff Edwards
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Formula = problem

Got it. Thank you.

"ward376" wrote:

You have a missing left parentheses and an extraneous dash in there.

Try recording the entry of the formula - you'll get something like
this...

Range("e5").FormulaR1C1 = _
"=MID(R[7]C,
1+FIND(CHAR(1),SUBSTITUTE(R[7]C,""\"",CHAR(1),LEN(R[7]C)-
LEN(SUBSTITUTE(R[7]C,""\"","""")))),255)"

Cliff Edwards

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula problem a Excel Discussion (Misc queries) 1 December 2nd 09 06:20 PM
Formula Problem Mark Hanson Excel Discussion (Misc queries) 2 September 12th 07 05:17 PM
Formula problem superkopite Excel Discussion (Misc queries) 8 January 27th 06 09:12 PM
formula problem Bart New Users to Excel 4 October 21st 05 12:56 PM
Problem with formula Sundaram Iyer Excel Discussion (Misc queries) 0 June 1st 05 12:49 AM


All times are GMT +1. The time now is 10:09 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"