+ Reply to Thread
Results 1 to 7 of 7

Deleting Rows Messes Up Formula

  1. #1
    Registered User
    Join Date
    06-06-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    50

    Deleting Rows Messes Up Formula

    Good Evening,


    Please Login or Register  to view this content.
    I have the following formula which list the row numbers of the number entered in C1 as well as matching the criteria. The formula works perfectly.

    However, the only problem is that there will be times I will be deleting entire rows from sheet2 which ruins my formula for some reason (as in the ranges changes e.g from A1:A100 to A1:A97). Is there any way to prevent this? I have read there I must use the index function, but i didn't know the correct syntax.



    Can anyone help?

    JJ

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,099

    Re: Deleting Rows Messes Up Formula

    Will you please attach a SMALL sample Excel workbook (10-20 rows of data is usually enough)? Please don't attach a picture of one (no-one will want to re-type all your stuff before starting).

    1. Make sure that your sample data are truly REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired solution is also shown (mock up the results manually).

    3. Make sure that all confidential information is removed first!!

    4. Try to avoid using merged cells. They cause lots of problems!

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Registered User
    Join Date
    06-06-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    50

    Re: Deleting Rows Messes Up Formula

    On sheet 2 it has the data. On sheet 1 in has the number u enter to search in cell C1 and in column D is where the formula should be and as you can see it list all the
    row numbers. In sheet 2, if you delete the row that is highlighted yellow, you will see it messes up the formula in sheet 1.
    Hope that makes sense.
    Attached Files Attached Files

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,099

    Re: Deleting Rows Messes Up Formula

    Try this:

    =IFERROR(SMALL(IF((Sheet2!$A$1:$A$100=C$1)*(Sheet2!B$1:B$100={"FW","DU","PU","SRP"}),ROW(Sheet2!$A$1:$A$100)),ROW(A1)),"")

    array entered.

  5. #5
    Registered User
    Join Date
    06-06-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    50

    Re: Deleting Rows Messes Up Formula

    Great, thank you so much!

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,240

    Re: Deleting Rows Messes Up Formula

    I would make columns A and B in sheet2 dynamic named ranges which expand/contract as rows are added/deleted

    For A

    Name: COL_A (Choose your name)

    set Refers to: =OFFSET(Sheet2!$A$1,,,COUNTA(Sheet2!$A$1:$A$1000),1)

    For B

    Name: COL_B

    =OFFSET(Sheet2!$B$1,,,COUNTIF(Sheet2!$B$1:$B$1000,"?*"),1)

    in D2=1 of Sheet1

    =IFERROR(SMALL(IF((COL_A=C$1)*(COL_B={"FW","DU","PU","SRP"}),ROW(COL_A)),ROW(A1)),"")

    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,099

    Re: Deleting Rows Messes Up Formula

    You're welcome...

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Insert blank row messes up formula
    By vienvy in forum Excel General
    Replies: 12
    Last Post: 06-28-2015, 01:11 AM
  2. [SOLVED] Need help with formula deleting rows
    By siumui00 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 10-10-2013, 05:17 PM
  3. Need help with formula deleting rows
    By siumui00 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-09-2013, 05:58 AM
  4. Replies: 2
    Last Post: 08-20-2013, 03:02 PM
  5. Array formula messes up my line chart.
    By DugiDug in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-24-2013, 08:41 AM
  6. Deleting rows causes formula to change
    By jgupte in forum Excel General
    Replies: 4
    Last Post: 08-20-2012, 08:39 PM
  7. Football league table - deleting empty cells messes it up
    By Potsdamerplatz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-11-2010, 12:51 PM

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