+ Reply to Thread
Results 1 to 15 of 15

Removing gaps from data extraction

  1. #1
    Registered User
    Join Date
    04-19-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    50

    Removing gaps from data extraction

    Hello
    I'm doing some simple data extraction, e.g.
    A B
    1 bob 3
    2 mandy 4
    3 charlie 6
    4 dave 1
    5 steve 5

    So I had in c1 to c5 = =if(b1 > 3, a1,"") autofilled, which works fine, but I end up with,

    gap
    mandy
    charlie
    gap
    steve

    how would I get,

    mandy
    charlie
    steve

    also is it possible to have an if statement in 1 cell change the value of another cell?

    e.g.
    in a1
    if(b1>5, c1="yes",c1="no"), can't seem to get it to work

    Thanks for your time.
    Last edited by sigfreid; 11-13-2009 at 09:22 AM.

  2. #2
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Removing gaps from data extraction

    Hello,

    You can try Advanced Filter ... and select Unique Values ...

    HTH

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Removing gaps from data extraction

    One way in xl2007

    select E1:E5 and then enter this array formula in E1, comit with CTRL+SHIFT+ENTER

    =IFERROR(INDEX(A1:A5,SMALL(IF(B1:B5>3,ROW(B1:B5),ROW(A6)),ROW(A1:A5))),"")
    Cheers
    Andy
    www.andypope.info

  4. #4
    Registered User
    Join Date
    04-19-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: Removing gaps from data extraction

    a unique filter wont work unfortunately as there will be duplicates of the records I wish to keep.

    Stuck using xl 2003 unfortunately.

    Quite happy to use VBA if it's doable in there!

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Removing gaps from data extraction

    just need to check for the error in pre '07

    =IF(ISERROR(INDEX(A1:A5,SMALL(IF(B1:B5>3,ROW(B1:B5),ROW(A6)),ROW(A1:A5)))),"",INDEX(A1:A5,SMALL(IF(B1:B5>3,ROW(B1:B5),ROW(A6)),ROW(A1:A5))))


    You might want to change you profile if you are not using 2007.

  6. #6
    Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2010
    Posts
    500

    Re: Removing gaps from data extraction

    Alternately, if your "gap" is a blank row you wish to remove, you can simply use the following vba code to identify blank cells in column A, then remove the entire row.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-19-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: Removing gaps from data extraction

    Thanks I'll give that a try, I have xl 2007 at home, at work it's 2003 they wont upgrade lol.

  8. #8
    Registered User
    Join Date
    04-19-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: Removing gaps from data extraction

    I may have perhaps over simplified this, I have a legal database with name, claim, claimed amount, settlement amount, etc, my boss basically wants to be able to put in a date or a date range and have it, pull out the entire rows where the date settled column has a matching date.

    I've tried some very basic things along the lines of

    if(date settled = date entered, then paste the entire row into a new workbook, else skip that row) which actually worked when it was just one row couldn't figure out how to make it do it for a range.

    I'm wondering if perhaps some kind of lookup or indexing may be easier or more efficient.

    this works
    Please Login or Register  to view this content.
    these don't
    Please Login or Register  to view this content.
    Last edited by sigfreid; 11-13-2009 at 10:49 AM.

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Removing gaps from data extraction

    Use AutoFilter then copy visible range to new worksheet.

  10. #10
    Registered User
    Join Date
    04-19-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: Removing gaps from data extraction

    Thanks that's sorted the gaps.

    About the selecting and copying of the records however, as I said this works

    Please Login or Register  to view this content.
    would it be possible to create like a case, where it checks P1 and then if it's valid, it loops until it's copied all of row 1, then moves onto Row 2, and checks P2 etc etc and so on, skipping to the next row straight away if P is invalid of course.

    Basically a shorter version of,
    Please Login or Register  to view this content.
    Last edited by sigfreid; 11-13-2009 at 11:20 AM.

  11. #11
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Removing gaps from data extraction

    You do not have to loop, just copy it all at once.
    See attached example.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    04-19-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: Removing gaps from data extraction

    I probably wasn't clear, this is the if statement before the filtering that generates the results to be filtered, I need to copy entire rows based on a value within that row and skip rows that lack said value.

  13. #13
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Removing gaps from data extraction

    Yep, you have managed to confuse me


    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    04-19-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: Removing gaps from data extraction

    Ah that's it, perfect, I just need that to loop, doing p1 then p2 then p3 and copying into a1 then a2 then a3 etc

    Skipping the rows where P is = to 0

    edit
    I figured it out o.o

    Please Login or Register  to view this content.
    Last edited by sigfreid; 11-13-2009 at 12:29 PM.

  15. #15
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Removing gaps from data extraction

    The code will create gaps in the outputted records on sheet4.
    If you only increment the j variable after a transfer then the gaps should disappear.

    Please Login or Register  to view this content.

+ 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