+ Reply to Thread
Results 1 to 13 of 13

extracting the largest number in an alphanumeric string

  1. #1
    Registered User
    Join Date
    01-06-2014
    Location
    leeds
    MS-Off Ver
    Excel 2010
    Posts
    4

    extracting the largest number in an alphanumeric string

    Hi folks,

    I'm trying to develop a "register" to record attendances at a Centre, as part of a membership spreadsheet.

    Rather than having 365 columns (one for each day they may attend) - I've got 52 columns as one per week is much more manageable. I've got it to work out the date of the Monday of each week for the top of the columns, and am considering having the cells include data that reflects which day of that week someone attends, and what they did: such as Monday="1", Tuesday="2" etc. and "g"=group, "P" = phonecall etc.
    The cells will therefore contain strings such as "1s2p" or "3c5p" or "4g" or blank.

    Thanks to other threads in this forum, I've managed to get other columns to display which is the most recent week they attended, and what they did in that week. What I would really like to do is to work out the date they last attended.

    I'm guessing that means extracting the largest number (of 1 to 7) from the string, and adding that to the date of the Monday of the week. However I can't find any simple way of extracting the largest number from a simple string

    Am I missing something ?

    PudseySquirrel

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: extracting the largest number in an alphanumeric string

    A formula like:
    =MAX(IF(ISERROR(1*MID(A1,ROW(A1:A1000),1)),0,1*MID(A1,ROW(A1:A1000),1)))
    entered as an array formula (confirm with ctrl+shift+enter), would return the largest (single digit) number from an alphanumeric string in A1.

  3. #3
    Forum Contributor
    Join Date
    03-28-2013
    Location
    *
    MS-Off Ver
    Excel 2010
    Posts
    226

    Re: extracting the largest number in an alphanumeric string

    can you post sample string and what you want extract from that string
    Give Feedback and Click(*)

  4. #4
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: extracting the largest number in an alphanumeric string

    And hey, if arrays aren't your thing and limiting your keystrokes isn't a worry you can use a little more of a brute force approach..


    =MAX(0,COUNTIF(A1,"*"&1&"*"),COUNTIF(A1,"*"&2&"*")*2,COUNTIF(A1,"*"&3&"*")*3,COUNTIF(A1,"*"&4&"*")*4,COUNTIF(A1,"*"&5&"*")*5,COUNTIF(A1,"*"&6&"*")*6,COUNTIF(A1,"*"&7&"*")*7,COUNTIF(A1,"*"&8&"*")*8,COUNTIF(A1,"*"&9&"*")*9)

    I could probably write an even longer formula if I had more time. And coffee.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  5. #5
    Registered User
    Join Date
    01-06-2014
    Location
    leeds
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: extracting the largest number in an alphanumeric string

    Thankyou for the very prompt response, Can I just ask what the Row(A1:A1000) refers to ? - it's asking for more arguments, and I guess it's doesn't want the Python sketch.

    Quote Originally Posted by yudlugar View Post
    A formula like:
    =MAX(IF(ISERROR(1*MID(A1,ROW(A1:A1000),1)),0,1*MID(A1,ROW(A1:A1000),1)))
    entered as an array formula (confirm with ctrl+shift+enter), would return the largest (single digit) number from an alphanumeric string in A1.

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: extracting the largest number in an alphanumeric string

    @daffodil,

    That would actually work better than my solution as an array formula as well:

    =MAX(COUNTIF(A1,"*"&ROW(A1:A7)&"*")*ROW(A1:A7))

    confirmed with ctrl+shift+enter.

    Edit:
    I'm not sure - I don't get the more arguments error when I try it.

    You can use Daffodil's non-array formula or the array formula version in this post.

  7. #7
    Registered User
    Join Date
    01-06-2014
    Location
    leeds
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: extracting the largest number in an alphanumeric string

    Thanks for the offer:

    Would love to have put this in a table, but it totally threw me !

    String returns:

    1c2g 2
    4p 4
    1p3p4p6u 6
    <blank> <blank>


    Quote Originally Posted by venkatpvc View Post
    can you post sample string and what you want extract from that string

  8. #8
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: extracting the largest number in an alphanumeric string

    Sweet.

    @Pudsey: It's a creative way to write a floating set of numbers. If you ever have questions about part of a formula, simply highlight a part of the formula in the formula bar and hit F9 to run the calculation on it. =row(a1:a7) turns into {1;2;3;4;5;6;7}, which means the formula is searching every nth character of the string, and checking if it's a number.

    F9 in the formula bar has taught me so much.

  9. #9
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: extracting the largest number in an alphanumeric string

    Try this formula

    =IFERROR(LOOKUP(2^15,FIND({1,2,3,4,5,6,7},A1),{1,2,3,4,5,6,7}),"")
    Audere est facere

  10. #10
    Registered User
    Join Date
    01-06-2014
    Location
    leeds
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: extracting the largest number in an alphanumeric string

    Hi folks,

    Well top marks for both daddylonglegs and daffodil there. Wow.

    Okay a bonus point if you can also suggest a way of then extracting into another cell what the letter after the highest number is. Thereby I can make two cells display what the last date and activity they took part in was . . .

    a highly impressed squirrel

  11. #11
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: extracting the largest number in an alphanumeric string

    May be:

    Array formula (Ctrl-shift-enter):

    =MAX(NOT(ISERROR(SEARCH(ROW(1:7),A1)))*ROW(1:7))

    Or non-array fomular:

    =MAX(NOT(ISERROR(SEARCH({1,2,3,4,5,6,7},A1)))*{1,2,3,4,5,6,7})
    Quang PT

  12. #12
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: extracting the largest number in an alphanumeric string

    ....actually even simpler for highest number

    =MATCH(2^15,FIND({1,2,3,4,5,6,7},A1))

    and assuming you have that formula in B1 use this formula for next letter

    =MID(A1,FIND(B1,A1)+1,1)

    or is that letter always the last in the string? If so just use

    =RIGHT(A1)

  13. #13
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: extracting the largest number in an alphanumeric string

    Another option to get the letter :
    =TRIM(RIGHT(SUBSTITUTE(A1,MAX(NOT(ISERROR(SEARCH({1,2,3,4,5,6,7},A1)))*{1,2,3,4,5,6,7}),REPT(" ",100)),100))

+ 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. Extracting Numbers from a Alphanumeric String
    By martinhardy in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-01-2013, 11:02 AM
  2. Replies: 12
    Last Post: 03-20-2013, 05:46 PM
  3. [SOLVED] Extracting information from an alphanumeric string
    By rafamocte in forum Excel General
    Replies: 14
    Last Post: 07-16-2012, 04:48 PM
  4. Extracting the nth number from an alphanumeric string
    By Chinchin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-15-2011, 02:38 PM
  5. Extracting alphanumeric value from the string.
    By AlKey in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-21-2009, 01:51 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