formula strings aggravation

alabamatoy

New Member
Joined
Oct 31, 2017
Messages
3
Excel 2013 macro code snippet:

Code:
ActiveCell.FormulaR1C1 = "=MID(D2,FIND(""."",D2,1)+1,FIND(""."",D2,FIND(""."",D2,1)+1)-FIND(""."",D2,1)-1)"

This formula within the quotes works (I'm using it in another excel file), but when the above code snippet sets the cell value, the actual resulting formula is:

Code:
=MID(D2,FIND(".",'D2',1)+1,FIND(".",'D2',FIND(".",'D2',1)+1)-FIND(".",'D2',1)-1)

which does NOT work. Why are there single quotes inserted around every cell reference, and how do I rectify this?

TIA....
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Correction, I left off one of the sets of single quotes:

Code:
=MID('D2',FIND(".",'D2',1)+1,FIND(".",'D2',FIND(".",'D2',1)+1)-FIND(".",'D2',1)-1)
 
Upvote 0
What cell is this being placed in?

Or actually yeah @Eric W is correct you could do it without the R1C1 mode
 
Last edited:
Upvote 0
so R1C1 works with rows and columns from where you currently are so if you are in cell C5 and you want to reference something in cell D8 it would be 1 Column to the right and 3 Rows down so that would mean that it would be R[3]C[1]...i belive the brackets make it absolute reference or i could have the backwards not sure
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top