+ Reply to Thread
Results 1 to 19 of 19

Need to check if specific number is part of a string

  1. #1
    Registered User
    Join Date
    04-17-2024
    Location
    India
    MS-Off Ver
    2019
    Posts
    6

    Need to check if specific number is part of a string

    I have a string in cell A1, such as "asdfk1234jh", and cell B1 contains the number "1234". I want to determine if the exact number in B1 is present within the string in A1. Existing solutions only return "TRUE" if any part of the number is found, like "12" or "123", but I require a formula to confirm if "1234" specifically exists in A1.
    Attached Files Attached Files
    Last edited by Spammerworld; 04-17-2024 at 03:55 AM. Reason: Adding attachment

  2. #2
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,990

    Re: Need to check if specific number is part of a string

    Welcome to the forum.

    Try this:

    =ISNUMBER(SEARCH("1234",A1))
    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.

  3. #3
    Registered User
    Join Date
    04-17-2024
    Location
    India
    MS-Off Ver
    2019
    Posts
    6

    Re: Need to check if specific number is part of a string

    Sorry, 1234 is just an example. B1 may contain any random number

  4. #4
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,990

    Re: Need to check if specific number is part of a string

    There are instructions at the top of the page explaining how to attach your sample workbook (yellow banner: HOW TO ATTACH YOUR SAMPLE WORKBOOK). Screenshots are of little practical use as we cannot manipulate them.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. The sample layout accurately matches that of your real data. It also has expected results mocked up, worked examples where required, relevant cells highlighted and a few explanatory notes.

  5. #5
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,990

    Re: Need to check if specific number is part of a string

    One way (there'll be a better solution, though):

    =MID(A1,MIN(IFERROR(SEARCH(CHAR(ROW(INDIRECT("48:57"))),A1),"x")),MAX(IFERROR(SEARCH(CHAR(ROW(INDIRECT("48:57"))),A1),"x"))-MIN(IFERROR(SEARCH(CHAR(ROW(INDIRECT("48:57"))),A1),"x"))+1)

    Enter with CTRL+SHIFT+ENTER.

  6. #6
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,990

    Re: Need to check if specific number is part of a string

    No reply ...

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED. You can also access the SOLVED tag by editing the opening post and choosing SOLVED from the drop-down to the left of the title box.

    Also, if you have not already done so, remember that you can reward anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of each of those who offered help.

  7. #7
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,990

    Re: Need to check if specific number is part of a string

    I see you have added a workbook to your opening post without telling us!

  8. #8
    Registered User
    Join Date
    04-17-2024
    Location
    India
    MS-Off Ver
    2019
    Posts
    6

    Re: Need to check if specific number is part of a string

    Thank you for your response. I've inserted the sample sample workbook, hope this would help you to better understand my requirement.

  9. #9
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,990

    Re: Need to check if specific number is part of a string

    Try this:

    =IFERROR(IF(--MID(A2,MIN(IFERROR(SEARCH(CHAR(ROW(INDIRECT("48:57"))),A2),"x")),MAX(IFERROR(SEARCH(CHAR(ROW(INDIRECT("48:57"))),A2),"x"))-MIN(IFERROR(SEARCH(CHAR(ROW(INDIRECT("48:57"))),A2),"x"))+1)=B2,"Yes","No"),"No")

    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

    Then copy down.

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

    Re: Need to check if specific number is part of a string

    I understand you correctly, I will try to search that number in text string (A2), then to chech whether one letter left and one letter right are alphabet or not. If both are, then "yes"
    ...x1234y....with x to the left and y to the right then yes

    Please Login or Register  to view this content.
    Quang PT

  11. #11
    Registered User
    Join Date
    04-17-2024
    Location
    India
    MS-Off Ver
    2019
    Posts
    6

    Re: Need to check if specific number is part of a string

    Thank you.. This works well.

  12. #12
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,990

    Re: Need to check if specific number is part of a string

    Glad to have helped.

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED. You can also access the SOLVED tag by editing the opening post and choosing SOLVED from the drop-down to the left of the title box.

    Also, if you have not already done so, remember that you can reward anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of each of those who offered help.

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

    Re: Need to check if specific number is part of a string

    Quote Originally Posted by Spammerworld View Post
    Thank you.. This works well.
    Which work? or both?

  14. #14
    Registered User
    Join Date
    04-17-2024
    Location
    India
    MS-Off Ver
    2019
    Posts
    6

    Re: Need to check if specific number is part of a string

    In my case, it returns "Yes" for any number starts with 123. For example, 1231 results in "Yes". Need slight changes in formula, I think.

  15. #15
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,990

    Re: Need to check if specific number is part of a string

    What does? My solution or Bebo's?

    Here's mine in action:

    AliGW on MS365 Beta Channel (Windows 11) 64 bit

    A
    B
    C
    D
    1
    String
    Number
    Result AliGW
    2
    SDFSDF1234FF
    1234
    Yes
    Yes
    3
    x2dfdfs1234dfF
    12
    No
    No
    4
    dsfsd325fgfdgh
    325
    Yes
    Yes
    5
    dsfsd325fgfdgh
    32
    No
    No
    6
    SDFSDF1234FF
    34
    No
    No
    Sheet: Sheet1
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    04-17-2024
    Location
    India
    MS-Off Ver
    2019
    Posts
    6

    Re: Need to check if specific number is part of a string

    Sorry, I'm a new user, and struggling to reply on the correct posts. #9 from AliGW works well

  17. #17
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,990

    Re: Need to check if specific number is part of a string

    Please see post #15 - the attachment shows BOTH formulae working well.

    Glad to have helped.

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED. You can also access the SOLVED tag by editing the opening post and choosing SOLVED from the drop-down to the left of the title box.

    Also, if you have not already done so, remember that you can reward anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of each of those who offered help.

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

    Re: Need to check if specific number is part of a string

    Special case:
    A1=xxx12345yyy1234zzz
    B1=1234
    both (Ali and me) give "No"
    what do you expect for this case?

  19. #19
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,990

    Re: Need to check if specific number is part of a string

    I'd spotted this possible issue, too - not sure what the solution would need to be for this scenario.

+ 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. Replies: 3
    Last Post: 03-21-2022, 09:21 AM
  2. [SOLVED] Code to check if a string is formatted correctly as a part number
    By Arnold Layne in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-20-2021, 01:03 PM
  3. Underline a specific part of a text string (inc formulas) using VBA.
    By Oriya in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-06-2019, 05:56 AM
  4. [SOLVED] Check if part of string is a number or letter
    By jakopak in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-16-2015, 09:13 AM
  5. Check if the last part of entered string is an Integer
    By szpt9m in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-08-2014, 11:08 PM
  6. [SOLVED] Extracting specific part of the text string to another column
    By ssanjju in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 01-20-2013, 07:20 PM
  7. [SOLVED] Finding specific text in string - Part II
    By Hardip in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-08-2006, 09:25 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