ActiveCell.FormulaR1C1 Put's Single Quotes Around Cell Reference

Billy Hill

Board Regular
Joined
Dec 21, 2010
Messages
73
I'm trying to get a formula into a cell from a macro and I'm getting a single quote isolating what should be a cell reference.

The current formula works fine, it looks like this:
=0.85+(75/D2290)+(0.3*0)

The formula I'm trying to make should come out like this, dividing D2290 by Cell K1:
=0.85+(75/(D2290*K1))+(0.3*0)

But it comes out like this instead with single quotes around the K1:
=0.85+(75/(D2290*'K1'))+(0.3*0)

This gives me a "#NAME" error.

Here is the code to create the formula that works:
ActiveCell.FormulaR1C1 = "=" & M & "+(" & P & "/RC[-3])+(.3*" & H & ")"

And here is the code that I thought would work but doesn't:
ActiveCell.FormulaR1C1 = "=" & M & "+(" & P & "/(RC[-3]*K1))+(.3*" & H & ")"

How do I get rid of the single quotes around the K1?

Thanks in advance!
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
I realized I need the cell referenced like $K$1 so I changed the forumla to

ActiveCell.FormulaR1C1 = "=" & M & "+(" & P & "/(RC[-3]*$K$1))+(.3*" & H & ")"

Now I get an error saying "Application defined or object-defined error.

Ack!
 
Last edited:
Upvote 0
Your formula is mixing RC and A1 references

Maybe this using A1 reference-style

Code:
ActiveCell.Formula = "=0.85+(75/(D2290*K1))+(0.3*0)"

Adjust ActiveCell to your target cell/range

M.
ps: i dont understand this part: +(0.3*0)
 
Upvote 0
You need to change K1 to it's R1C1 equivalent.
 
Upvote 0
Your formula is mixing RC and A1 references

Maybe this using A1 reference-style

Code:
ActiveCell.Formula = "=0.85+(75/(D2290*K1))+(0.3*0)"

Adjust ActiveCell to your target cell/range

M.
ps: i dont understand this part: +(0.3*0)

The formula is built with variables so I create it with code. I used the recorder to get the basics and modified it from there, hence using the R1C1 method. Is there a better way?

What the code does is calculate a material and plating cost. I use 3 input boxes to get the material cost, the plating cost and the number of plugged holes.

The +(0.3*0) is used if there are holes to be plugged before plating. They cost $.30 each to plug.
 
Upvote 0
Glad it worked.

I was going to post what it might have been but if it wasn't an absolute reference then the R1C1 could depend on where the formula was going.
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,550
Members
452,927
Latest member
rows and columns

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