+ Reply to Thread
Results 1 to 8 of 8

How to retain formula when inserting rows?

  1. #1
    Registered User
    Join Date
    06-18-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2000
    Posts
    6

    How to retain formula when inserting rows?

    Hi guys, I need some help.


    Lets say I'm creating an Excel spreadsheet that will calculate the sum of cells A1:D1. The formula is stored in cell E1. I then drag the formula in E1 down to E100. This spreadsheet is to be handed over to someone else to use.

    Here's my problem. If that person inserted a row in A30, the cell in E30 would now be blank. There is no formula in E30 anymore that will compute the sum of A30:D30. It is also important for E30 to display the sum in addition to calculating it.

    I've seen some solutions online where the problem is solved via a different method of inserting row? Unfortunately I have no control over how a row will be inserted by the people using my spreadsheet.

    I need a solution without resorting to VBA or a macro. Can anyone help?
    Last edited by redryder; 06-18-2009 at 11:45 PM.

  2. #2
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,014

    Re: How to retain formula when inserting rows?

    Perhaps you might consider to move formula of E column to another sheet.

    HTH,

    windknife

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to retain formula when inserting rows?

    Quote Originally Posted by windknife View Post
    Perhaps you might consider to move formula of E column to another sheet.
    This is half the solution, because even on the second sheet the formulas would adjust themselves downward if a row was inserted on the first sheet. At least it would if the formula was a direct reference.

    Instead, on sheet2, to sum A1:D1, use an indirect reference. In row 1 on sheet2 somewhere put this formula:

    =SUM(INDIRECT("Sheet1!A" & ROW() & ":D" & ROW()))
    ...then copy that down 150 rows.

    Now you will get the sum of all the active rows, no matter what happens on Sheet1 with inserting/deleting rows.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    06-18-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2000
    Posts
    6

    Re: How to retain formula when inserting rows?

    Quote Originally Posted by JBeaucaire View Post
    This is half the solution, because even on the second sheet the formulas would adjust themselves downward if a row was inserted on the first sheet. At least it would if the formula was a direct reference.

    Instead, on sheet2, to sum A1:D1, use an indirect reference. In row 1 on sheet2 somewhere put this formula:

    =SUM(INDIRECT("Sheet1!A" & ROW() & ":D" & ROW()))
    ...then copy that down 150 rows.

    Now you will get the sum of all the active rows, no matter what happens on Sheet1 with inserting/deleting rows.

    Thanks but that's still only half a solution right? I need the sum of A1:D1 to be displayed on E1 on the first sheet. If someone inserts a row(e.g. row 100), and enters data into A100:D100, E100 would be still be blank on Sheet 1 regardless of what happens in Sheet2.

    1. How do I display the sum (A100:D100) on E100?
    OR
    2. How do I prevent someone else from inserting rows, but still allowing them to enter data in the cells?

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to retain formula when inserting rows?

    Oh, why didn't you ask that originally. Simple...protect your sheet. When you protect your sheet you get to pick which cells are locked and which are not, and decide things like allowing insertions/deletions.

  6. #6
    Registered User
    Join Date
    06-18-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2000
    Posts
    6

    Re: How to retain formula when inserting rows?

    Quote Originally Posted by JBeaucaire View Post
    Oh, why didn't you ask that originally. Simple...protect your sheet. When you protect your sheet you get to pick which cells are locked and which are not, and decide things like allowing insertions/deletions.
    I think my Excel 2000 does not have those options. All I see are checkboxes for "Contents", "Objects" and "Scenarios" under the Protect Sheet dialog box. Nothing about inserts/deletions.

    Ok, what if I use a VBA script that disables all the insert commands? I found some code online that would do it for the main menu bar, but I can't find the code to disable Insert in the right-click menu. Any help there?

  7. #7
    Forum Contributor mubashir aziz's Avatar
    Join Date
    03-18-2009
    Location
    Lahore, Pakistan
    MS-Off Ver
    MS Office 2013
    Posts
    533

    Re: How to retain formula when inserting rows?

    IMO: you should upgraded to at least 2003 as before a faced a lot lot of problems while using 2000.
    If this post helps, Please don't 4get to click the star icon located at the bottom left of my Post.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to retain formula when inserting rows?

    RedRyder, be careful about using the "QUOTE" button, only use that if you're specifically noting something said by someone in an earlier post, and even then probably best to cut out the rest. Just use the QUICK-REPLY to converse normally and keep the thread from filling up with unnecessary quoting.

    If you have a new Q go ahead and post that in the PROGRAMMING forum as a separate question. Make sure you point out this is an Excel 2000 specific need.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1