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

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
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,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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