+ Reply to Thread
Results 1 to 10 of 10

Formule to split data (from "1999 - 2001" to "1999 2000 2001")

  1. #1
    Registered User
    Join Date
    02-23-2011
    Location
    Hasselt
    MS-Off Ver
    Excel 2007
    Posts
    5

    Formule to split data (from "1999 - 2001" to "1999 2000 2001")

    Hi Everybody,

    8've been looking for a few days for a formula that allows me to write in full certain years:

    This is what I mean:
    Value: 1999 - 2004
    Value after formula: 1999 2000 2001 2002 2003 2004

    Need something in the direction of
    2004-1999 = 5
    1999 (1999+1) (1999 +2) (1999 +3) (1999+4) (1999+5)
    or 1999 (1999+1) ((1999+1)+1) etc until 5 is reached

    Thanks for looking at this.

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

    Re: Formule to split data (from "1999 - 2001" to "1999 2000 2001")

    Assuming the spans vary then in reality a single cell native formula is not really viable / practical (IMO)

    You could however consider using a basic UDF:

    Please Login or Register  to view this content.
    The above stored in a standard Module in VBE could be called from a cell along the lines of:

    Please Login or Register  to view this content.
    where A1 holds 1999-2004 etc.. this would return the delimited string.
    Last edited by DonkeyOte; 02-23-2011 at 09:58 AM. Reason: shortened per example

  3. #3
    Registered User
    Join Date
    02-23-2011
    Location
    Hasselt
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Formule to split data (from "1999 - 2001" to "1999 2000 2001")

    Worked!

    Just had to do a figure out the VBE,...

    Butt it did the trick,

    Thank you very much

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

    Re: Formule to split data (from "1999 - 2001" to "1999 2000 2001")

    =if($a1="","",if(column(a1)-1>right($a1,4)-left($a1,4),"",left($a1,4)-1+column(a1)))
    "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

  5. #5
    Registered User
    Join Date
    02-23-2011
    Location
    Hasselt
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Formule to split data (from "1999 - 2001" to "1999 2000 2001")

    Hi Everybody,

    I would like to come back to this topic.
    You've helped me a lot with the split years formula.

    Now I need to reverse it.

    From:
    2001 2002 2003 2004 2005

    To:
    2001 - 2005

    Can anyone push me in the right direction?

    Thanks,

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: Formule to split data (from "1999 - 2001" to "1999 2000 2001")

    Here: =LEFT(C6,4)&" - "&RIGHT(C6,4)

  7. #7
    Registered User
    Join Date
    02-23-2011
    Location
    Hasselt
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Formule to split data (from "1999 - 2001" to "1999 2000 2001")

    Quote Originally Posted by zbor View Post
    Here: =LEFT(C6,4)&" - "&RIGHT(C6,4)
    Thanks, it worked!

    Only had to change , to ;

    =LEFT(C6;4)&" - "&RIGHT(C6;4)

  8. #8
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: Formule to split data (from "1999 - 2001" to "1999 2000 2001")

    Glad to help...

    I guess I shouldn't change ; to , in a first place

  9. #9
    Registered User
    Join Date
    02-23-2011
    Location
    Hasselt
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Formule to split data (from "1999 - 2001" to "1999 2000 2001")

    and to keep it interesting;-)

    Now I have the following issue:

    Orginal:
    2001 2002 2003 2004 2005
    2003 2004 2005 2006 2007 2008 2009 2010
    2003
    2005 2006

    After formula:
    2001 - 2005
    2003 - 2010
    2003 - 2003
    2005 - 2006

    When there's only 1 year available it should stay one year!
    See the 2003 value.Any work around for this?

    Thanks,

  10. #10
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: Formule to split data (from "1999 - 2001" to "1999 2000 2001")

    There can be several approaches... You could check LEN, or ISNUMBER etc.

    This approach look is there a space in the word (note: if you have 2003_ (space) you will get 2003-2003 again)...

    =LEFT(G12;4)&IF(ISERR(FIND(" ";G12));"";" - "&RIGHT(G12;4))

+ 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