+ Reply to Thread
Results 1 to 7 of 7

Formula error after deleting rows

  1. #1
    Registered User
    Join Date
    08-21-2003
    Posts
    45

    Formula error after deleting rows

    I have this formula:
    =IF(C1=35,SUM(D4:D38)+D41+D42+D43,SUM(D4:D31)+D34+D35+D36)

    But when I delete rows 32-38 it changes to this formula:
    =IF(C1=35,SUM(D4:D31)+D34+D35+D36,SUM(D4:D31)+#REF!+#REF!+#REF!)

    And that results in an output value of #REF!

    How do I make it so that when I delete those 7 rows, the formula calculates the sum of the shortened range?

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Formula error after deleting rows

    The IDEAL solution is to NOT delete those rows.
    Could you instead just "Clear Contents" of those rows?

  3. #3
    Registered User
    Join Date
    08-21-2003
    Posts
    45

    Re: Formula error after deleting rows

    It's a spreadsheet I use at work and people would wonder why there's a bunch of blank rows.

    I was hoping there'd be a way I can adjust the formula so that it would ignore the rows that got deleted when C1 becomes 28 instead of 35.

  4. #4
    Registered User
    Join Date
    11-14-2012
    Location
    Derby, England
    MS-Off Ver
    Excel 2013
    Posts
    32

    Re: Formula error after deleting rows

    You could adjust the first occurance of formula manually, lock any references you don't want to change ($) then drag the new formula over the area again.

    or

    You could just hide the rows you don't want, instead of deleting them.
    If somebody helps you, say thanks, by clicking *

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Formula error after deleting rows

    you have this...
    =IF(C1=35,SUM(D4:D38)+D41+D42+D43,SUM(D4:D31)+D34+D35+D36)
    and then you delete the rows that the bolded part references (plus a few extra 32:38 either side), so excel is kinda saying...+ ummm errr wait, those references dont exist any more, tell me what to do???

    Im surprised the 1st part didnt throw out an error too...SUM(D4:D38)

    Probably the vbest thing would be to either delete the #REF references (use find/replace) or just hide those empty rows?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Formula error after deleting rows

    you could try
    =IF(C1=35,SUM(INDIRECT("D4:D36"),INDIRECT("D41:D42")),SUM(INDIRECT("D4:D31"),INDIRECT("D34:D36")))
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  7. #7
    Registered User
    Join Date
    08-21-2003
    Posts
    45

    Re: Formula error after deleting rows

    Quote Originally Posted by martindwilson View Post
    you could try
    =IF(C1=35,SUM(INDIRECT("D4:D36"),INDIRECT("D41:D42")),SUM(INDIRECT("D4:D31"),INDIRECT("D34:D36")))
    Beautiful, Martin!

+ 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