Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
ntscott
 
Posts: n/a
Default The reference changes when I insert a row?!?! Help

I've created a worksheet that uses a macro. The macro adds a line at the top
of the worksheet. I have some cells that total from different columns. I
thought that changing the formula in the totals cells to an absolute
reference should work...I want the formula in the total box to always add the
cells from D9 on down the line...In my totals cell I wrote =sum($D$9:$D$500).
When I run the macro, it moves all of my rows down 1 row and inserts a new
row 9. When I click on my totals cell to read the formula, it now reads
=sum($D$10:$D$501). HELPPPPP!

  #2   Report Post  
PeterAtherton
 
Posts: n/a
Default



"ntscott" wrote:

I've created a worksheet that uses a macro. The macro adds a line at the top
of the worksheet. I have some cells that total from different columns. I
thought that changing the formula in the totals cells to an absolute
reference should work...I want the formula in the total box to always add the
cells from D9 on down the line...In my totals cell I wrote =sum($D$9:$D$500).
When I run the macro, it moves all of my rows down 1 row and inserts a new
row 9. When I click on my totals cell to read the formula, it now reads
=sum($D$10:$D$501). HELPPPPP!


Why not get the macro to insert a formula. If the total goes in d8 add the
line

range("D8").formula = "=sum(D9:D500)"

Adding the extra rows will make the formula future proof.

Regards
Peter
  #3   Report Post  
Ron Coderre
 
Posts: n/a
Default

This formula will *always* start your range at D9:
=SUM(INDIRECT("$D$9"):$D$500)

Note: Inserting rows will extend the range downwards.

Does that help?

Ron

  #4   Report Post  
Ken Wright
 
Posts: n/a
Default

Start your sum from one row above, ie row 8 and make that row blank (maybe
shrink it a bit too)

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------

"ntscott" wrote in message
...
I've created a worksheet that uses a macro. The macro adds a line at the

top
of the worksheet. I have some cells that total from different columns. I
thought that changing the formula in the totals cells to an absolute
reference should work...I want the formula in the total box to always add

the
cells from D9 on down the line...In my totals cell I wrote

=sum($D$9:$D$500).
When I run the macro, it moves all of my rows down 1 row and inserts a new
row 9. When I click on my totals cell to read the formula, it now reads
=sum($D$10:$D$501). HELPPPPP!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Maintaining cell reference after sorting GRITS Excel Discussion (Misc queries) 2 April 30th 23 07:42 PM
insert picture BillGwyer Excel Discussion (Misc queries) 1 March 4th 05 06:37 PM
Challenging Charting C TO Charts and Charting in Excel 0 January 17th 05 06:57 PM
How can I insert a cell reference in a footer (eg for variable foo GW Excel Discussion (Misc queries) 1 December 15th 04 10:58 AM
How can I insert a cell reference in a footer (eg for variable foo wngg001 Excel Discussion (Misc queries) 1 December 15th 04 10:56 AM


All times are GMT +1. The time now is 06:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"