# 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]:RC[-7],RC[-7],RC:RC)"

End If
Next

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

### Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

#### 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
65
Replies
3
Views
89
Replies
18
Views
244
Replies
5
Views
57
Replies
2
Views
151

Threads
1,127,997
Messages
5,628,040
Members
416,287
Latest member
wanji

### Share this page ### 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