+ Reply to Thread
Results 1 to 11 of 11

Formula to rearrange contents of a cell

  1. #1
    Registered User
    Join Date
    02-27-2007
    Posts
    14

    Formula to rearrange contents of a cell

    Example: Cell A2 displays the following contents:
    02/27/2007
    is there a formula I can use to rearrange the cell contents to change to
    20070227

  2. #2
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    If cell A2 is a clean date format, you just need to Format Cell Custom
    yyyymmdd ...
    HTH
    Carim


    Top Excel Links

  3. #3
    Forum Contributor
    Join Date
    03-14-2006
    Location
    Pakistan
    Posts
    1,791

    Lightbulb

    Quote Originally Posted by Whougonacall
    Example: Cell A2 displays the following contents:
    02/27/2007
    is there a formula I can use to rearrange the cell contents to change to
    20070227
    you need to do some work
    select the entire column which contains such type of data.
    go to menu Data > Text to Columns... and use / as delimiter.
    it will split you data in three columns (say col A, B and C).
    now in col D put following function.
    =C1&B1&A1 and copy it down.

    (you can copy data to a blank sheet to try this procedure)

  4. #4
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Quote Originally Posted by Whougonacall
    Example: Cell A2 displays the following contents:
    02/27/2007
    is there a formula I can use to rearrange the cell contents to change to
    20070227
    Try this,

    =DATE(RIGHT(A2,4),LEFT(A2,2),MID(A2,4,2)) custom format cell to yyyymmdd
    oldchippy
    -------------


    Blessed are those who can give without remembering and take without forgetting

    If you are happy with the help you have received, please click the <--- STAR icon on the left - Thanks.

    Click here >>> Top Excel links for beginners to Experts

    Forum Rules >>>Please don't forget to read these

  5. #5
    Forum Contributor
    Join Date
    03-14-2006
    Location
    Pakistan
    Posts
    1,791

    Lightbulb

    Quote Originally Posted by oldchippy
    Try this,

    =DATE(RIGHT(A2,4),LEFT(A2,2),MID(A2,4,2)) custom format cell to yyyymmdd
    Hi Oldchippy

    Carim's tip seems better than using formula, because you even need to change format of the cell as Carim mentioned.

  6. #6
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Quote Originally Posted by starguy
    Hi Oldchippy

    Carim's tip seems better than using formula, because you even need to change format of the cell as Carim mentioned.
    Hi starguy,

    Agreed Carim's works fine if the date is in a number format, but if it is text that doesn't work.

  7. #7
    Registered User
    Join Date
    02-27-2007
    Posts
    14
    Thanks for your help guys I will give this a try and get back to you with which way worked best for me

  8. #8
    Registered User
    Join Date
    02-27-2007
    Posts
    14
    Quote Originally Posted by oldchippy
    Try this,

    =DATE(RIGHT(A2,4),LEFT(A2,2),MID(A2,4,2)) custom format cell to yyyymmdd
    Thank you Old Chippy!

    But this turned cell a2's contents of 02/27/2007 into 27/02/2007 so it just turned MM/DD/YYYY into DD/MM/YYYY

    How can I urn it into YYYYMMDD (please note I am not using fwd slash here as I would rather this without)

    So far Star Guy's suggesion has work, however i'd be interested in a formula that can do this too.

    Thanks for our help

  9. #9
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Quote Originally Posted by Whougonacall
    Thank you Old Chippy!

    But this turned cell a2's contents of 02/27/2007 into 27/02/2007 so it just turned MM/DD/YYYY into DD/MM/YYYY

    How can I urn it into YYYYMMDD (please note I am not using fwd slash here as I would rather this without)

    So far Star Guy's suggesion has work, however i'd be interested in a formula that can do this too.

    Thanks for our help
    Hi Whougonacall,

    Use the formula I have suggested, then right click on the cell with 27/02/2007, Format cells > Category, choose Custom, you will see in the "Type" box dd/mm/yy, click in the box and change to yyyymmdd click OK. Your date now is 20070227 exactly as you wanted

    Hope this helps

  10. #10
    Registered User
    Join Date
    02-27-2007
    Posts
    14
    Thanks for the info this is great allworked fine

  11. #11
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Glad to hear we have a result - thanks for the feedback

+ 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