# Debug Errors on R1C1 Formulas

#### KHaag

##### New Member
I keep getting debug errors when trying to insert a formula and copy it down the column. Here is the data that I am using:

and here is the code for inserting the formulas for QMD and REL DENSITY (Note that the values for the variables myLastRow and CellValue have previously been defined):

'insert formulas for QMD
Range("K5").Select
ActiveCell.FormulaR1C1 = "=SQR(RC[-1]/RC[-2])/0.005454)"
'
'insert formulas for Relative Density
For Each Cell In Range("L5:L" & myLastRow)
CellValue = "=(R,C[-5]"
If CellValue = "Intermediate" Then
ActiveCell.FormulaR1C1 = "=(183.35/((R,C[-1])^2)*(-0.024257+(0.024257*(R,C[-1]))+(0.0015225*(R,C[-1])^2))*(R,C[-2])"
ElseIf CellValue = "Slow" Then
ActiveCell.FormulaR1C1 = "=(183.35/((R,C[-1])^2)*(-0.0027935+(0.0058959*((R,C[-1]))+(0.004729*K3^2))*((R,C[-2])"
ElseIf CellValue = "Fast" Then
ActiveCell.FormulaR1C1 = "=(183.35/((R,C[-1])^2)*(0.0033033+(0.020426*((R,C[-1]))+(0.0006776*((R,C[-1])^2))*((R,C[-2]))"
Else
ActiveCell.Formula = "=SUMIF(=SUMIF(RC[-7]:R[10000]C[-7],RC[-7],RC:R[10000]C)"

End If
Next

The Debug errors have happened on the SQR formula and the SUMIF formula.
Thank you,
Kim

### Excel Facts

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.

#### RoryA

##### MrExcel MVP, Moderator
None of your formulas appear to be valid. You have commas between R and C that shouldn’t be there, and two =SUMIF functions in the last one.

#### KHaag

##### New Member
RoryA, Thank you for your response.

I've cleaned up the formulas, but am still getting a debug error on the SQR formula. I haven't pulled out the code for the formulas in the For statement, so I don't know yet if there are still issues there.

Thanks again,

Kim

#### StephenCrump

##### MrExcel MVP
You need SQRT for an Excel formula, not VBA's SQR. And you have one extra ")"

ActiveCell.FormulaR1C1 = "=SQRT(RC[-1]/RC[-2]/0.005454)" will work, although you may need to adjust the formula depending on what you want?

If you want the same formula down the column, then you can use the one line:

Range("K5:K" & myLastRow).Formula = "=SQRT(J5/I5/0.005454)"

I'd build the Intermediate/Slow/Fast into a single Excel formula, rather than hard-coding into VBA, so that your formulae remain dynamic to changes in column G.

#### KHaag

##### New Member
Stephen, I used your suggestion for putting the formula down the column for both formulae and it worked beautifully!!
Thank you so much!
Kim

Replies
1
Views
53
Replies
3
Views
85
Replies
18
Views
236
Replies
5
Views
54
Replies
2
Views
135

1,127,594
Messages
5,625,693
Members
416,127
Latest member
MALEPINZON

### 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.

### Which adblocker are you using?

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

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