+ Reply to Thread
Results 1 to 26 of 26

Numberic Indicies converted to Names

  1. #1
    Registered User
    Join Date
    03-02-2018
    Location
    Washing DC
    MS-Off Ver
    Office 10
    Posts
    12

    Numberic Indicies converted to Names

    Okay brain trust...I KNOW there's got to be an easier way to do this, other than brute force.

    So here's what I'm trying to do. Let's say I have a table where things are listed but with an indices indicating indent level

    (NOTE: I know this example isn't really logically correct..but hopefully it conveys the problem)
    1 Month
    1.1 January
    1.2 February
    2 WeekDay
    2.1 Monday
    2.2 Tuesday
    2.2.1 22nd

    Now say I want to convert 1.1 to Month.January
    and convert 2.2 to Weekday.Tuesday
    and convert 2.2.1 to Weekday.Tuesday.22nd

    anyone have an ideas?

    I had a couple ideas...but they start getting tricky the lower down in levels I got.

    Idea #1: I was thinking of using the "." delimiter to break out the numberical into various columns. meaning, instead of one column going down that has
    1
    1.1
    2
    2.1

    I'd break it out like this:
    1
    1 1
    2
    2 1

    Then I could just replace all 1's in the first column with "Month" And all all 2's in the first column with "Weekday". Then similarly in the 2nd column. The problem is...in the 2nd column, if it's a 1....is it a 1 from 1.1 or from 2.1. So now we have to lookup the 1st column to properly convert the 2nd column. This gets particularly messy when I have 5 or 6 levels down (2.1.4.3.13.2)

    Idea #2: write a macro that looks at the number and counts the number of "." then add's 1. And in a new table, puts the text (i.e. "Tuesday") in that column. so if 2.1.4.3.13.2 has a value of "milli-seconds"...then "milli-seconds" would be put in the 6th column. If all of these are in order, I believe we'd end up with a table that has rows ike this:

    Month Weekday Day Hour Second Milli-Second

    Then, once that table's complete, I just spit it out to text with my "." delimiter. So I'd ultimately end up with:

    "Month.Weekday.Day.Hour.Second.Milli-Second"

    but while I can figure out how to count the "." in the original number...not sure how to write a macro that would copy text into certain columns on a new page.

    Or maybe there's even an easier way. Any help would be appreciated.
    Last edited by skeety; 03-02-2018 at 07:06 PM.

  2. #2
    Registered User
    Join Date
    03-02-2018
    Location
    South Carolina
    MS-Off Ver
    2016
    Posts
    8

    Re: Numberic Indicies converted to Names

    What I'd suggest is using Text to Columns with a "." as the delimiter. This will break all the numbers into separate columns.
    Then you can use multiple IF formulas to get what you want. You can either do these in separate columns and concatenate, or use one big formula with &"."& in between IF functions.

    Another way is if you already have the "legend" (i.e. a range of all possible #.#.# values and the result) then you can just use VLOOKUP.

    A third way is using the MID function to extract the first character, third, fifth, etc.
    Last edited by dryphi; 03-02-2018 at 07:28 PM.

  3. #3
    Registered User
    Join Date
    03-02-2018
    Location
    Washing DC
    MS-Off Ver
    Office 10
    Posts
    12

    Re: Numberic Indicies converted to Names

    Yeah...my initial thought was VLOOKUP as well (see idea #1). But then realized I would end up with nested conditional VLOOKUPS. Almost 3-dimensional VLOOKUPs. and I don't think excel can handle that, can it?

  4. #4
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: Numberic Indicies converted to Names

    Three dimensional lookups are possible with the INDEX(CHOOSE, MATCH, MATCH) construction or similar. It requires a "cubic" data set up though.

    But I think that might be the wrong direction.

    Text-to-columns would work, and then you'd use the array construction of {INDEX(output, MATCH(input1&input2, range1&range2, 0))} to grab a one-and-only-one match... but you might need to daisy-chain a bunch of them together with concatenation, and wrapped in IFERROR(do, "") to accomplish what you need, I think.

    Also don't forget,
    Excel stores the date (day-month-year) as an integer, counting starting form zero on Jan 1st, 1900;
    and time is stored as a float, with zero at midnight, noon at 0.5, and wrapping around to 0.99 at 11:59 PM or such; and time can include decimals of a second (eg, milliseconds).

    So you can store all that data as a single value in the cell, and then display that however you want with formatting (I think custom format mmm.ddd.dd hh:mm:ss.000 is about what you want?). I dunno if that's what you want to do, but that can be an end-goal you work towards. I might be a little leery about that because I'd worry about floating-point arithmetic errors though, I'd probably do some testing.
    Click the [* Add Reputation] Button to thank people for help!
    Post Attachment: Click [Go Advanced] under the reply box; then click [Manage Attachments] to launch the attachments dialogue.
    Mark Thread Solved: Go to the top of the first post; Select [Thread Tools] dropdown; Pick the [Mark thread as Solved] option.

  5. #5
    Registered User
    Join Date
    03-02-2018
    Location
    Washing DC
    MS-Off Ver
    Office 10
    Posts
    12

    Re: Numberic Indicies converted to Names

    that helps a little.

    Can you give me an example of the approach your recommending, using my dates example?

    Just as an FYI...I was using dates here as an example. This is actually a massive system requirements table. I didn't want to confuse the question with all that. hehe

  6. #6
    Registered User
    Join Date
    03-02-2018
    Location
    South Carolina
    MS-Off Ver
    2016
    Posts
    8

    Re: Numberic Indicies converted to Names

    Seems like you have a limited set of values for each parameter, correct?
    For instance Month can only be 12 different values, Weekday only 7, Hour 24, Second 60, and millisecond also 60. Maybe you can use six VLOOKUPS with the MID function and concatenate the result.
    Can you post the Excel file?
    Last edited by dryphi; 03-02-2018 at 07:39 PM.

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Numberic Indicies converted to Names

    How about ...

    A
    B
    C
    D
    E
    1
    Level
    WBS
    Item
    2
    1
    1 Month Month D3: =IF(A3 = 1, "", LOOKUP(1, 1/(A$1:A2 < A3), D$1:D2) & ".") & C3
    3
    2
    1.1 January Month.January
    4
    2
    1.2 February Month.February
    5
    1
    2 WeekDay WeekDay
    6
    2
    2.1 Monday WeekDay.Monday
    7
    2
    2.2 Tuesday WeekDay.Tuesday
    8
    3
    2.2.1 22nd WeekDay.Tuesday.22nd


    You can use a formula to calculate level from WBS if need be.
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Registered User
    Join Date
    03-02-2018
    Location
    Washing DC
    MS-Off Ver
    Office 10
    Posts
    12

    Re: Numberic Indicies converted to Names

    Unfortunately, I can not. It's proprietary system requirements.

  9. #9
    Registered User
    Join Date
    03-02-2018
    Location
    Washing DC
    MS-Off Ver
    Office 10
    Posts
    12

    Re: Numberic Indicies converted to Names

    Did your formula get cut-off?

    D3: =IF(A3 = 1, "", LOOKUP(1, 1/(A$1:A2 < A3), D$1:D2) & ".") & C3

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Numberic Indicies converted to Names

    Quote Originally Posted by skeety View Post
    Did your formula get cut-off?
    Nope, that's all there is.

  11. #11
    Registered User
    Join Date
    03-02-2018
    Location
    Washing DC
    MS-Off Ver
    Office 10
    Posts
    12

    Re: Numberic Indicies converted to Names

    I get that formula to give me D2...but is the formula similar for D3?

    I'm not getting it to work past level 1...

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Numberic Indicies converted to Names

    Paste the formula in the formula bar sans curly braces, press and hold the Ctrl and Shift keys, then press Enter.

    Then copy down.

  13. #13
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Numberic Indicies converted to Names

    Oops -- never mind, it doesn't need to be array-entered. It works exactly as shown.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    03-02-2018
    Location
    Washing DC
    MS-Off Ver
    Office 10
    Posts
    12

    Re: Numberic Indicies converted to Names

    shg,

    Think I just thought of the easiest way...but it's dependent upon them being IN ORDER:

    =IF(A3 > A2, CONCATENATE(C2,".", C3), C3)
    Last edited by jeffreybrown; 03-02-2018 at 08:38 PM. Reason: Removed full quote!

  15. #15
    Registered User
    Join Date
    03-02-2018
    Location
    Washing DC
    MS-Off Ver
    Office 10
    Posts
    12

    Re: Numberic Indicies converted to Names

    D'oh...wait...this won't handle situations where the levels are equal. ie.

    Level
    1
    2
    2 <- Will break here...

    hmmm...getting closer though.

  16. #16
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Numberic Indicies converted to Names

    ... deleted ...

  17. #17
    Registered User
    Join Date
    03-02-2018
    Location
    Washing DC
    MS-Off Ver
    Office 10
    Posts
    12

    Re: Numberic Indicies converted to Names

    shg,

    Yes. hehe...I know how to copy the formula out...but it's fills out the level 1's fine...but all the rest end up "0"
    Last edited by jeffreybrown; 03-02-2018 at 08:38 PM. Reason: Removed full quote!

  18. #18
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Numberic Indicies converted to Names

    Did you look at the attached workbook?

  19. #19
    Registered User
    Join Date
    03-02-2018
    Location
    South Carolina
    MS-Off Ver
    2016
    Posts
    8

    Re: Numberic Indicies converted to Names

    How about =IF(LEN(A3)=3,C2&"."&C3,C3)
    You could do multiple nested IF statements for the condition where the length of the string in colum A is 1, 3, 5, 7, 9 and 11 characters long.

    Also, just FYI using the & symbol is easier than typing the word "concatenate"
    Last edited by dryphi; 03-02-2018 at 08:38 PM.

  20. #20
    Registered User
    Join Date
    03-02-2018
    Location
    Washing DC
    MS-Off Ver
    Office 10
    Posts
    12

    Re: Numberic Indicies converted to Names

    I ended up getting shg's formula working. When I converted it to the cell #'s in my table, I was off by one.

    HUGE help! THanks.

  21. #21
    Registered User
    Join Date
    03-02-2018
    Location
    Washing DC
    MS-Off Ver
    Office 10
    Posts
    12

    Re: Numberic Indicies converted to Names

    AAAAkkk.

    ALMOST working. It's messing up when looking up nested levels.

    it works for 1.2.1

    but later, when it finds 3.2.1, it's pulling in the x.2.x value from 1.2.1

    meaning

    Section1
    --Subsection1_FOO
    ----extraSubsection1
    Section2
    --Subsection1_WOOT
    ----extraSubsection1
    Section3
    --Subsection1_BOOP
    ----extraSubsection1


    Instead of getting Section3.Subsection1_BOOP.extraSubsection1 for 3.1.1
    I'm getting Section3.Subsection1_FOO.extraSubsection1

  22. #22
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,923

    Re: Numberic Indicies converted to Names

    Or try this:

    =LOOKUP(10^10,$A$2:A2,$G$2:G2)&IF(COUNT(B2:F2),"."&LOOKUP(10^10,$B$2:B2,$G$2:G2),"")
    &IF(COUNT(C2:F2),"."&LOOKUP(10^10,$C$2:C2,$G$2:G2),"")&IF(COUNT(D2:F2),"."&LOOKUP(10^10,$D$2:D2,$G$2:G2),"")
    &IF(COUNT(E2:F2),"."&LOOKUP(10^10,$E$2:E2,$G$2:G2),"")&IF(COUNT(F2),"."&G2,"")

    Please see the attached.
    Attached Files Attached Files
    Last edited by Phuocam; 03-02-2018 at 09:48 PM.

  23. #23
    Registered User
    Join Date
    03-02-2018
    Location
    South Carolina
    MS-Off Ver
    2016
    Posts
    8

    Re: Numberic Indicies converted to Names

    Mostly works except row 4 says "Month.January.February"

    EDIT: That was actually a data entry mistake in column 2. There wouldn't be a case where a column is skipped afaik.
    Last edited by dryphi; 03-02-2018 at 10:27 PM.

  24. #24
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Numberic Indicies converted to Names

    Sorry, there was a mistake in my formula, corrected below.

    A
    B
    C
    D
    E
    1
    Level
    WBS
    Item
    2
    1
    1 Section1 Section1 D3: =IFERROR(LOOKUP(2, 1/(A$1:A2 < A3), D$1:D2) & ".", "") & C3
    3
    2
    1.1 Subsection1_FOO Section1.Subsection1_FOO
    4
    3
    1.1.1 extraSubsection1 Section1.Subsection1_FOO.extraSubsection1
    5
    1
    2 Section2 Section2
    6
    2
    2.1 Subsection2_WOOT Section2.Subsection2_WOOT
    7
    3
    2.1.1 extraSubsection1 Section2.Subsection2_WOOT.extraSubsection1
    8
    1
    3 Section3 Section3
    9
    2
    3.1
    Subsection1_BOOP Section3.Subsection1_BOOP
    10
    3
    3.1.1 extraSubsection1 Section3.Subsection1_BOOP.extraSubsection1
    Last edited by shg; 03-03-2018 at 12:14 PM.

  25. #25
    Registered User
    Join Date
    03-02-2018
    Location
    Washing DC
    MS-Off Ver
    Office 10
    Posts
    12

    Re: Numberic Indicies converted to Names

    BOOM goes the Dynomite!!

    Thank you SOOOOO much shg, and everyone else!

    Saved me tons of time...as there were over 550 of these....

  26. #26
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,417

    Re: Numberic Indicies converted to Names

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to read cells values from a converted to excel (converted to exe file)
    By AttalaEA in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-04-2014, 02:57 AM
  2. Replies: 3
    Last Post: 07-27-2013, 04:57 AM
  3. [SOLVED] Finding a numberic value that does not have a subset.
    By ACFHogan in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-24-2012, 09:44 AM
  4. Problems with indicies in For loops, it works with integers but not the index.
    By msfarrar in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-22-2012, 10:46 AM
  5. Find numberic values
    By yoonus.it in forum Excel General
    Replies: 1
    Last Post: 08-27-2007, 05:07 AM
  6. Formula for last numberic value in column
    By Phil Hageman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-14-2005, 10:05 AM
  7. [SOLVED] alpha numberic cell
    By clambake5 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-17-2005, 07:06 PM

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