+ Reply to Thread
Results 1 to 9 of 9

checking a string

  1. #1
    Registered User
    Join Date
    06-25-2012
    Location
    haifa, israel
    MS-Off Ver
    Excel 2007
    Posts
    7

    checking a string

    Hi,

    I have a list of various strings I need to check and match them to the same format the correct format is:
    _"something"(a mix of capital letters and numbers)_"another something"_"one letter(out of 4 optional letters)"_"number".pdf(has to be in small letters)
    Example:_GTF392847_234_U_15.pdf, _YRTFC892659345_32A439854_B_373.pdf.

    Is there a way to do this check?

    Thanks,
    Dani

  2. #2
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: checking a string

    Yes you could a number of ways (e.g. regular expressions) however you need to put this into context. Have you got these strings in separate cells or are they derived from something - could you perhaps upload a sample workbook showing your data and explain what exactly you want to do. Obviously you are constructing a pdf file name. Do you just want to check that the file name matches a specific format as in your examples. Could you elaborate and if you have a sample workbook with some sample data show exactly what you are trying to achieve. I guess what you want is - does this file string match a set of rules - we need to know the rules e.g. mix of capital letters and numbers that is how long? e.g. one letter (what are the 4 optional letters) e.g. what is range of 3 digit number
    Once you construct a file string you could use a regular expression to see if it matches your rules however we need to know the rules to be able to help you and as I say if you have a sample workbook if would make things easier - you need to elaborate on your question as the easy answer is YES you can validate the string construction but without rules impossible to create code to check rules match.
    Hope this helps.
    Anthony
    Pack my box with five dozen liquor jugs
    PS: Remember to mark your questions as Solved once you are satisfied. Please rate the answer(s) by selecting the Star in the lower left next to the Triangle. It is appreciated?

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,538

    Re: checking a string

    UDF

    =IsFormatCorrect(A1,"ABCU")

    where 2nd arg is the option string.

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    06-25-2012
    Location
    haifa, israel
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: checking a string

    Hi again,

    Sorry for not being completely clear so again the basic format is:_A_B_C_D.pdf
    A=a mix of capital letters and numbers. Length varies and is not consistent.
    B=also a mix between capital letters and numbers can also include "-" and also varies in length.
    C= one of 4 capital letters U,B,C,S
    D=a number between 1-9999.

    Also important ".pdf" has to be in small letters.

    What I'm trying to achieve is listing those strings in column A and then knowing which ones are not in the right format in order to correct the format
    A
    _HDT257863100A1_2007-11-652_U_15.pdf
    _1232658_235_C_289.pdf
    _LLL21385400_2009-05-008_S_654.pdf
    _TRAY873_353_B_89.pdf

    I'm sorry I can't upload files from this computer...

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,538

    Re: checking a string

    Change the Pattern to
    Please Login or Register  to view this content.
    And formula should look like

    =IsFormatCorrect(A1,"UBCS")

  6. #6
    Registered User
    Join Date
    06-25-2012
    Location
    haifa, israel
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: checking a string

    I'm probably doing something wrong. It gives me a "#NAME?" error

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,538

    Re: checking a string

    See attached
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: checking a string

    Jindon has written you a User Defined Function - it is like a new function that you can use in a worksheet - it is in a module - see attached workbook.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    06-25-2012
    Location
    haifa, israel
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: checking a string

    It works! Awesome! Thanks

+ 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