View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Updating Code when a row is inserted

The best way to accomplish what you want is to use define names on the
worksheet. Go to worksheet menu Insert - Names - Define.

You can define the following cells
abc as C5
xyz as C127

Then in VBA
Range("abc") = Range ("xyz")

When rows are deleted the workjsheet will automatically update the define
range and VBA will also be updated.
"ML" wrote:


Hi I have a lot of VBA code in a budget spread sheet.
When a person inserts a row, I need my macros to somehow update dynamically.

One "small" example would be on my calculate worksheet event
If the user inserts a row, at 127 for example, then the value of cell C5 is
lost.
Is there a way to C127 become C128 if a row is inserted?

Thank you,
Mark

Private Sub Worksheet_Calculate()

'Extra Cash Cells in Row 5 = Extra Cash Cells in Row 127
Range("C5").Value = Range("C127")
Range("D5").Value = Range("D127")
Range("E5").Value = Range("E127")
Range("F5").Value = Range("F127")
Range("G5").Value = Range("G127")