Reference error

Lisa928

Board Regular
Joined
Jun 13, 2002
Messages
173
I have a spreadsheet that has the following information in column A. A simple calculation that I use as a line id.

A1 = 1
A2 = A1+1
A3 = A2+1
A4 = A3+1
A5 = A4+1

The problem is that this file is updated frequently and sometimes rows need to be removed. Is there any way through a formula (or VBA if not) that I can stop this from happening?
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

paliman

Active Member
Joined
Jul 7, 2002
Messages
254
I made this with the macro recorder. May be it needs some adjustments

Sub Macro2()

Range("A1").Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = "=+R[-1]C+1"
Selection.Copy
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub
 

paliman

Active Member
Joined
Jul 7, 2002
Messages
254
The former code won't stop it from hapening, but it will update your formulas after deleting rows.
 

Forum statistics

Threads
1,144,359
Messages
5,723,893
Members
422,524
Latest member
wirkkarn

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
Top