+ Reply to Thread
Results 1 to 13 of 13

Find Highest Alphanumeric value containing

  1. #1
    Registered User
    Join Date
    11-16-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2010
    Posts
    5

    Find Highest Alphanumeric value containing

    Hi all, could someone please assist me with the correct code to find the highest alphanumeric number containing specific alpha characters? the format will always be the same: two numbers, three alpha, four numbers - 12ABC1234
    first two digits are the year the number is assigned, followed by a 3 character location key, then a sequential number
    for example, sheet 2 column d contains a list like
    20CDA0002
    20ABC0005
    20DCD0003
    20ABC0006
    I need to find the highest value containing the given key, eg. DCD, and suggest the next number - 20DCD0004

    Any help would be appreciated.
    Last edited by thatmasonkid; 07-09-2020 at 12:50 PM. Reason: corrected title

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    13,764

    Re: Find Highest Alphanumeric value containing

    Welcome on the excelforum

    Non VBA solution

    B1 =Countif($A$1:$A1,$C$1)

    C1 = 20DCD*

    D1 =LEFT($C$1,5)&TEXT(RIGHT(INDIRECT(ADDRESS(MATCH(MAX($B$1:$B$5),$B$1:$B$5,0),1)),3)+1,"000")

    See the attached file.
    Attached Files Attached Files
    Last edited by oeldere; 07-09-2020 at 01:41 PM.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Registered User
    Join Date
    11-16-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Find Highest Alphanumeric value containing

    Thanks for the quick reply, I should have stated that I'm looking for a VBA solution, as this event is to take place as part of a userform.

  4. #4
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    13,764

    Re: Find Highest Alphanumeric value containing

    That is why I added

    Non VBA solution

  5. #5
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Türkiye
    MS-Off Ver
    2010 - 64 Bit
    Posts
    785

    Re: Find Highest Alphanumeric value containing

    @thatmasonkid;

    Assuming that the data is listed in cells D2:D5 on the active sheet, you can try the below code:

    Please Login or Register  to view this content.
    Last edited by Haluk; 07-09-2020 at 02:56 PM. Reason: typo...

  6. #6
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 2010, 2019
    Posts
    1,990

    Re: Find Highest Alphanumeric value containing

    Here is a non-RegExp procedure that you can consider...
    Please Login or Register  to view this content.
    Note: The Test macro calls the NextMax function, which is what performs the actual desired calculation... the macro just shows how to call the function from within other VBA code. The function itself can be used as a UDF directly on the worksheet if desired.

  7. #7
    Registered User
    Join Date
    11-16-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Find Highest Alphanumeric value containing

    I think that's very close, but I'm getting a run time error 5 - Invalid procedure call or argument error on this line
    newVal = "20" & strCode & Format(WorksheetFunction.Max(myArr) + 1, "0000")

    I'm a over my head on how to address it, but I'm searching.

  8. #8
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Türkiye
    MS-Off Ver
    2010 - 64 Bit
    Posts
    785

    Re: Find Highest Alphanumeric value containing

    As i've stated in my message #5; check that your data is in the range "D2:D5" and if not, change the below line accordingly;

    Please Login or Register  to view this content.
    Also, check that the sheet housing the data is the active sheet when you run the code.

    .

  9. #9
    Registered User
    Join Date
    11-16-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Find Highest Alphanumeric value containing

    Thanks Rick, this results in a Type mismatch on the NextMax line, I'm trying to wrap my head around it now.

  10. #10
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Türkiye
    MS-Off Ver
    2010 - 64 Bit
    Posts
    785

    Re: Find Highest Alphanumeric value containing

    @thatmasonkid; sample file is attached....
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    11-16-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Find Highest Alphanumeric value containing

    I had corrected the range using with/end with to grab it from the other sheet, so the other sheet was not active.
    Activating the sheet got rid of the error and works like a charm now.
    THANKS!

  12. #12
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 2010, 2019
    Posts
    1,990

    Re: Find Highest Alphanumeric value containing

    Sorry, I did not realize you would be running this from another sheet. You can fix that by referencing the worksheet that the data is on in the Test macro (see what I highlighted in red which is assuming your data is on a worksheet named Sheet1)...
    Please Login or Register  to view this content.

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    18,769

    Re: Find Highest Alphanumeric value containing

    Quote Originally Posted by thatmasonkid View Post
    for example, sheet 2 column d contains a list like
    20CDA0002
    20ABC0005
    20DCD0003
    20ABC0006
    I need to find the highest value containing the given key, eg. DCD, and suggest the next number - 20DCD0004
    Try
    Please Login or Register  to view this content.

+ 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. Return highest Alphanumeric value from a list
    By earl2grey in forum Excel General
    Replies: 14
    Last Post: 10-24-2018, 06:17 PM
  2. [SOLVED] VBA expression to extract the text from the beginning of an alphanumeric string
    By webfeet2 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-01-2012, 12:41 AM
  3. VBA code to find highest and 2nd highest number based in criteria
    By Michael007 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-25-2011, 08:38 AM
  4. Finding the Highest Value in alphanumeric strings
    By Barking_Mad in forum Excel General
    Replies: 6
    Last Post: 10-28-2009, 04:04 PM
  5. Removing numbers from the beginning of alphanumeric cells
    By .excelhelper. in forum Excel General
    Replies: 2
    Last Post: 08-19-2009, 01:48 PM
  6. Return Highest Alphanumeric Value
    By raehippychick in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-14-2009, 08:24 AM
  7. Replies: 2
    Last Post: 09-19-2008, 10:22 AM

Tags for this Thread

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