variable absolute cell reference

uti1301

New Member
Joined
Jul 17, 2017
Messages
18
I have 7 columns C to I, all of the same length. I want to enter formulae in rows after the last cell in column I. The formulae include an absolurte cell regerence to the last cell in Column I.
For example, if the last row of column I is row number 12, the formula in cell I13 would be R12C6 + RC[-6]*(R12C7)+R[-12]C[-1], and similarly for the following rows.
However the length of column I can vary, depending on the input data, so the absolute cell reference needs to be variable.

The code I am using for 11 additional rows is:

Sub test1()
Range("I1").End(xlDown'Range("I13").Select
Var = (ActiveCell.Row - 1)
For ltcount = 0 To 11
ActiveCell.Offset(ltcount, 0).FormulaR1C1 = "=R" & Var & " C6 + RC[-6]*(R " & Var & " C7)+R[-12]C[-1]"
Next ltcount
End Sub

When I run this, I get an error, but I can't see what is wrong.

If someone can tell me what I am doing wrong, I would be grateful.

Thanks, any help would be much appreciated
 

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.
Thank you for your reply Brian.
I have found the error: it was in line 5 of my code.
The application now works OK
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

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