+ Reply to Thread
Results 1 to 17 of 17

names to numbers

  1. #1
    Forum Contributor
    Join Date
    09-13-2010
    Location
    Poland
    MS-Off Ver
    365
    Posts
    204

    names to numbers

    Hi,

    I have problem with change of names of the months to numbers. however, this is just a part of what I am doing. I will go with whole process step by step, pls also see the excel table attached:
    1. I one of the columns I have this kind text "2010/jul/29". this is not being seen as date by excel, but as text. each cell has different data
    2. so, to make excel see it as a text, I need to break it into its constituent and then use the formula Date
    3. this formula has 3 subcategories: year, month, day. and excel needs numbers, not text to make it work. so the problem occures in month part. that is "jul" (or any other, like "jun", "sep"
    4. I need a macro or update formula, that could change the text to number, and I need to add it to my Data formula.
    5. I have placed the ready formula in the excel table attached. I do not paste it here, because my formula is not in english, but your excel will read it in your language. date/text is in A1, formula is in C1

      thanks for your help in creating of new formula or macro.
    Attached Files Attached Files
    Last edited by afgi; 10-05-2010 at 08:21 AM.

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: names to numbers

    If your data is always in *exactly* the same format then this formula will convert it to a real date...

    Please Login or Register  to view this content.
    If the day of the month is sometimes one digit and sometimes two then that will require a little tweak.

  3. #3
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: names to numbers

    PS - that formula is based on your data being in cell A2, if that wasn't clear.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: names to numbers

    All the parameters in a DATE() formula have to be numeric, but you've used text functions to pull out the pieces. Each piece needs to be converted back into a number, like so:

    =DATE(LEFT(A1,4)+0, MONTH(MID(A1, FIND("/", A1)+1, 3)&1), RIGHT(A1,2)+0)
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: names to numbers

    Why do you use '2010/jul/29' instead of '29/jul/2010' ?



  6. #6
    Forum Contributor
    Join Date
    09-13-2010
    Location
    Poland
    MS-Off Ver
    365
    Posts
    204

    Re: names to numbers

    Hi,

    this is date downloaded from web page, sequence is the result of page administartors. reg formulas, may I ask you to always attached excel file with your formulas. I have excel in polish, so sometimes it is hard for me to find counterparts of your english formulas. I am not so fluent in excel

  7. #7
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: names to numbers

    And another way....

    This will convert your string to an actual date.
    Please Login or Register  to view this content.
    You can then format the cells:= yyyy/mmm/dd

    Hope this helps
    Attached Files Attached Files
    Last edited by Marcol; 10-05-2010 at 06:31 AM. Reason: Added workbook for OPs' benefit
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  8. #8
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: names to numbers

    or

    =DATEVALUE(RIGHT(A1;2) & "-" & MID(A1;6;LEN(A1)-8) & "-" & LEFT(A1;4))

  9. #9
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: names to numbers

    or with VBA:

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

  10. #10
    Forum Contributor
    Join Date
    09-13-2010
    Location
    Poland
    MS-Off Ver
    365
    Posts
    204

    Re: names to numbers

    Hi,

    do you know maybe how to create User define function that combines code
    Please Login or Register  to view this content.
    and function that has been created in this thread? pls see those in the excel file attached. column A is the text I have at the begining. column C is a result of above User Defined Function. Column G is function that changes text to proper date format. So I need to comnbine this process into one User Defined Function or a macro. many thanks
    Attached Files Attached Files

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: names to numbers

    FYI, my formula works as entered on the spreadsheet above. Simply select the cell I2, press F2 and ENTER to reassert the formula.

  12. #12
    Forum Contributor
    Join Date
    09-13-2010
    Location
    Poland
    MS-Off Ver
    365
    Posts
    204

    Re: names to numbers

    Dear Jerry,

    I need it to extract information directly from column A f.e. A2. and I want to have a User Defined Formula to be made. I do not know how to creat one.
    I need it to work on many workbooks, that is why i do not wont to copy& paste this formula each time I work on different files. many thanks

  13. #13
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: names to numbers

    Please Login or Register  to view this content.
    put into cell B1:

    =date_01(A1)

  14. #14
    Forum Contributor
    Join Date
    09-13-2010
    Location
    Poland
    MS-Off Ver
    365
    Posts
    204

    Re: names to numbers

    Dear SNB,

    does not work

  15. #15
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: names to numbers

    You are right.

    therefore you'd better not use a function but the macro I gave you earlier: for instance the dates are in column A:

    the only code you need is:

    Please Login or Register  to view this content.

  16. #16
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: names to numbers

    I'm a bit lost in this thread, but in reply to your PM
    Please Login or Register  to view this content.

    This will cover for the possibility of blanks and "nearly" dates.

    See attachment for all the solutions offered compared
    Attached Files Attached Files

  17. #17
    Forum Contributor
    Join Date
    09-13-2010
    Location
    Poland
    MS-Off Ver
    365
    Posts
    204

    Re: names to numbers

    works great
    Last edited by afgi; 10-19-2010 at 10:45 AM.

+ 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