+ Reply to Thread
Results 1 to 14 of 14

Search for P followed by four numbers

  1. #1
    Registered User
    Join Date
    12-01-2014
    Location
    Brussels
    MS-Off Ver
    2007
    Posts
    4

    Search for P followed by four numbers

    Hi everyone,

    I would like to search a cell for a string "p" followed by four numbers. Eg. P0400

    Any ideas?
    Thanks,

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Search for P followed by four numbers

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: Search for P followed by four numbers

    Searching can be done many ways. One way would be to use filters, then click on text filters and you can select "begins with..." or "Contains..." or some other parameter. It is difficult to give you a more detailed answer without more information or as 6th sense noted - a sample file with before and after.
    If you just need a formula then a left formula would work but you don't say if the P is always on the far left side of the cell or the lengths are consistent where a P would be found.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  4. #4
    Registered User
    Join Date
    12-01-2014
    Location
    Brussels
    MS-Off Ver
    2007
    Posts
    4

    Re: Search for P followed by four numbers

    Sorry. Here you go!

    Thank you so much for your time and effort!
    Attached Files Attached Files
    Last edited by wanjaf; 12-02-2014 at 09:16 AM.

  5. #5
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Search for P followed by four numbers

    see the attached file
    Attached Files Attached Files
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  6. #6
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Search for P followed by four numbers

    Maybe this

    =IF(LEN("P"&SUBSTITUTE(TRIM(RIGHT(SUBSTITUTE(A4,"P",REPT(" ",25)),25)),".",""))=5,"Yes","No")
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  7. #7
    Registered User
    Join Date
    12-01-2014
    Location
    Brussels
    MS-Off Ver
    2007
    Posts
    4

    Re: Search for P followed by four numbers

    Brilliant, nflsales! Thank you so much. But isn't it weird that if I replace "P0500" in cell A4 to "P1500" the function returns no Yes nor No (= error)?

    Alkey, your solution works too, thank you! However when I add some characters behind the P-code (E.g. "P0111 some more text") the function returns "No".
    Last edited by wanjaf; 12-02-2014 at 10:35 AM.

  8. #8
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Search for P followed by four numbers

    Dear wanjaf. You can always count on getting more accurate results if you provide more accurate complete requirements. Unfortunately, this wasn't the case.

  9. #9
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Search for P followed by four numbers

    See if this one will work better

    =IF(MID(A4,LOOKUP(25^25,MIN(IFERROR(FIND({0,1,2,3,4,5,6,7,8,9},A4),""))-1),1)="P","Yes","No")

    Row\Col
    A
    B
    3
    Title Title contains P-code?
    4
    TPA Wire-harness - wrong assembly - DTC P0500 Yes
    5
    Front Pass Side rear airbag sensor malfunction (DTC B1630) No
    6
    Automatic gearbox malfunction DTC:P2714. Yes
    7
    Tire pressure monitor bulb functional [ Poor ] (C2121) No
    8
    Automatic gearbox malfunction DTC:P2714POII Yes
    9
    Front Pass Side rear airbag sensor malfunction (DTC :P0156POPYYY Yes
    Last edited by AlKey; 12-02-2014 at 11:45 AM.

  10. #10
    Registered User
    Join Date
    05-10-2013
    Location
    Pomáz, Hungary
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Search for P followed by four numbers

    Try this formula in B2, confirm with Ctrl – Shift – Enter, not just Enter:

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    12-01-2014
    Location
    Brussels
    MS-Off Ver
    2007
    Posts
    4

    Re: Search for P followed by four numbers

    Thank you, Alkey! Your formula works perfectly. Sorry I was not clear from the beginning.

    Thank you as well, István Hirsch, your formula works too when I confirm with Ctrl – Shift – Enter!
    Last edited by wanjaf; 12-03-2014 at 02:55 AM.

  12. #12
    Registered User
    Join Date
    05-10-2013
    Location
    Pomáz, Hungary
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Search for P followed by four numbers

    Please check. At me:

    Formula in #9 says „YES” for P1 or P21 etc., not only for P1234 and says „NO” for P1234xx.

    Formula in #5 says „YES” for P1234567 and says nothing for xxxP1xxxP1234 or xxx2xxxP1234

  13. #13
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Search for P followed by four numbers

    You're welcome and thank you for the feedback!

    Please mark thread as "Solved" if your issue has been resolved. (Selecting Thread Tools -> Mark thread as Solved).

  14. #14
    Registered User
    Join Date
    05-10-2013
    Location
    Pomáz, Hungary
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Search for P followed by four numbers

    Quote Originally Posted by AlKey View Post
    You're welcome and thank you for the feedback!

    Please mark thread as "Solved" if your issue has been resolved. (Selecting Thread Tools -> Mark thread as Solved).
    Please check:

    Your formula in #9 does not check the number of digits following „P” so it gives false positive for any number of digits following „P”, for example for P1, P12, P123, P1234567 etc.
    It gives false negative if a P1234 structure is preceded by any number, for example xx2xxP1234.

+ 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. [SOLVED] search for all unique numbers down a column and print a list of those numbers in another
    By JJGF in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-05-2014, 11:08 PM
  2. [SOLVED] Search Group of Numbers in Cel Rangel and Highligh matched numbers.
    By david gonzalez in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-24-2013, 01:07 AM
  3. [SOLVED] "how to search missing numbers in a single cell "from a min/max numbers library.."
    By david gonzalez in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-22-2012, 04:58 PM
  4. Replies: 2
    Last Post: 02-27-2012, 12:24 PM
  5. search for numbers
    By waishno in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-20-2007, 02:24 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