+ Reply to Thread
Results 1 to 6 of 6

Removing the gaps in numbers using formulae

Hybrid View

  1. #1
    Registered User
    Join Date
    11-13-2009
    Location
    Cape Town, South Africa
    MS-Off Ver
    Excel 2003
    Posts
    2

    Removing the gaps in numbers using formulae

    I've got some formulae that extract numbers from rows of text. These need to act as index numbers for a bunch of other stuff. But only some rows have numbers in them the rest are blank. So my number column that extracts the text goes something like this:

    1




    2




    2a

    3

    etc.

    Now I want people to be able to paste the text into the appropriate column. Once the numbers are then extracted for them automatically, on a summary sheet, I need to see:

    1
    2
    2a
    3

    like so. But I don't want my users to have to do any filtering. I want the numbers to appear by formulae. Now I've easily got it to do it with vb - a counter goes down, picks up a number, deposits it in the column on the other sheet which iterates its own counter, and so on until it runs out of numbers.

    But I also don't want to have to have embedded macros in the sheet either, so that people feel more free about sharing and using the final book.

    Is there any way that my summary sheet can have in that number column a formula that will retrieve each number in sequence, i.e.:

    Row1: formula1 will retrieve: 1
    Row2: formula2 will retrieve: 2
    Row3: formula3 will retrieve: 2a
    Row4: formula4 will retrieve: 3

    The ultimate object is that the end user plugs the text in. My text formulae find and extract the numbers into an adjacent cell - if index numbers are found with that row.

    On the summary sheet, the formulas I'm asking about retrieve the index numbers found by the text formulae and lay them down in a column, in sequence, ignoring blanks.

    The end user doesn't have to do anything at all.

    Any thoughts, or am I just being stupid?

  2. #2
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Removing the gaps in numbers using formulae

    try this

    =IF(ISERROR(INDEX($B$2:$B$14,SMALL(ROW($B$2:$B$14)-1+(10000000*ISBLANK($B$2:$B$14)),ROW()-1),1)),"",INDEX($B$2:$B$14,SMALL(ROW($B$2:$B$14)-1+(10000000*ISBLANK($B$2:$B$14)),ROW()-1),1))

    NOTE the 2 red 1's are the row number the first formula is in -1

    so if you start in A2, 1 is correct, if you start in b10 this should be 9

    confirm with CSE then copy down
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


  3. #3
    Registered User
    Join Date
    11-13-2009
    Location
    Cape Town, South Africa
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Removing the gaps in numbers using formulae

    Thanks a bunch. I'll try this out and let you know how it goes. There's stuff in here that I had no idea about.

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

    Re: Removing the gaps in numbers using formulae

    It might be worth posting a sample - a slightly different take:

    Summary!A2:
    =IF(ROWS(A$2:A2)>COUNTIF(Data!$B$2:$B$14,"?*"),"",INDEX(Data!$B$2:$B$14,SMALL(IF(Data!$B$2:$B$14<>"",ROW(Data!$B$2:$B$14)-ROW(Data!$B$2)+1),ROWS(A$2:A2))))
    confirmed with CTRL + SHIFT + ENTER (enter alone will not suffice)
    copied down
    above assumes that Data!B2:B14 are text strings which is implied...

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

    Re: Removing the gaps in numbers using formulae

    avoiding an array like that id go for a helper column this can be placed on a completely different sheet if you don't want to see it
    Attached Files Attached Files
    "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

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

    Re: Removing the gaps in numbers using formulae

    Quote Originally Posted by martindwilson View Post
    avoiding an array like that id go for a helper column...
    I love to see people championing helper cells so good call !

    That said... ... if the number of non-blanks is limited then the approach I posted should not prove too expensive given the Array is only performed for as many times as there are values to retrieve.

+ 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