+ Reply to Thread
Results 1 to 8 of 8

How do you delete rows without affecting formulas?

  1. #1
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    How do you delete rows without affecting formulas?

    In general, when you write a formula:

    In Cell A1:

    Please Login or Register  to view this content.
    And then a macro deletes 10 Rows from that range, the formula changes to:

    Please Login or Register  to view this content.
    Is there a way to fix that range even when rows are deleted?

    I can think of a few workarounds [including some VBA], but I would think Excel should have an easier way already built-in.

    Thanks for any help or assistance.

    modytrane
    Last edited by modytrane; 09-28-2009 at 02:58 PM. Reason: SOLVED

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How do you delete rows without affecting formulas?

    INDEX

    =SUM(INDEX(A:A,4):INDEX(A:A,100))

    You can use INDIRECT too but unlike INDEX that is Volatile.

    If you intend to delete Column A in entirety then you need to adjust the INDEX range accordingly (to a matrix and add 1 (column_num)) which will work unless you intend to delete the sheet in full... at which point you need INDIRECT.

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: How do you delete rows without affecting formulas?

    Try using instead

    =Sum($A$4:INDEX($A:$A,100))
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  4. #4
    Registered User
    Join Date
    09-23-2009
    Location
    Montreal
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: How do you delete rows without affecting formulas?

    one way to do it... what i use... is to utilise the INDIRECT function... I mean, instead of
    =SUM(D2:D100)
    use
    =SUM(INDIRECT("D2:D100"))

    But this is more difficult to copy, because it just takes range like a simple text... and cannot modify it...
    What I do, I use the normal function, and after, with a series of replaceses i transform the formula with INDIRECT...

    But this is just one way...

  5. #5
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: How do you delete rows without affecting formulas?

    Thank you all for you responses.
    Here's the formula I am using. How do you modify this formula?
    I tried the index method, it doesn't work in this formula.


    Please Login or Register  to view this content.
    The Formula is on one sheet and it references a range on another sheet [i.e. "Points List"]. I have macros that delete rows from that range.

    Any suggestions?

    Thank again,
    modytrane

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: How do you delete rows without affecting formulas?

    You tried?

    Please Login or Register  to view this content.

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How do you delete rows without affecting formulas?

    Though I would make the point that using C4:INDEX(...) rather than INDEX:INDEX is still open to error if row 4 is deleted.

  8. #8
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: How do you delete rows without affecting formulas?

    Thanks NBVC, it works.
    I wasn't using proper syntax.

    DonkeyOte,
    Your point is well taken.
    However, in my case the macro stops at Row5. I had the extra row in my formula just for safety.

    Thanks to both of you, learned something new.
    modytrane.

+ 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