+ Reply to Thread
Results 1 to 7 of 7

Find Exact Number from a String in cell (InStr(13,"1.2.13.4") >> gives 6 i/o 0)

  1. #1
    Registered User
    Join Date
    06-30-2015
    Location
    Israel
    MS-Off Ver
    MS Office 2003, 2010, 2013
    Posts
    6

    Find Exact Number from a String in cell (InStr(13,"1.2.13.4") >> gives 6 i/o 0)

    Good Day all

    struggling this issue for a couple of hours....
    It a rather small issue but could not figure out how to solve it.

    In one cell I have a string such as 1.2.3.4 and i want to find if this string contains a number appear in other cell, lets say cell $A$1 = 3.
    I’ve able to do it with Instr(A1,”1.2.13.4″)...OR with Search Formula, BUT

    The problem is when i have a string such as: 1.2.13.4 , it "looks" on the 3 (remember...on cell $A$1) and returned 6 , as if this number is part of the string.
    But i want to check if string contain 13 NOT 3.

    Any help will be appreciated !!!

    Posted as well on: http://www.ozgrid.com/forum/showthread.php?t=201899
    and on: http://vbaf1.com/q/a/check-if-string-in-a-cell/
    Shlomi
    Last edited by Shlomi.unique; 11-27-2016 at 09:54 AM.

  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,410

    Re: Find Exact Number from a String in cell (InStr(13,"1.2.13.4") >> gives 6 i/o 0)

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).
    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
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Find Exact Number from a String in cell (InStr(13,"1.2.13.4") >> gives 6 i/o 0)

    Add a . at the beginning and end of your string; so 1.2.3.4 becomes .1.2.3.4. Then search for "."&$D$1&"." in that string, assuming D1 contains the number you're searching for,. It'll find 3 but not 13.

    So, with data starting in A1:

    =SEARCH("."&$D$1&".","."&A1&".")
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  4. #4
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,899

    Re: Find Exact Number from a String in cell (InStr(13,"1.2.13.4") >> gives 6 i/o 0)

    Or try this ...

    =IFERROR(LEN(LEFT("."&A1,FIND("."&$D$1&".","."&A1&".")))-LEN(SUBSTITUTE(LEFT("."&A1,FIND("."&$D$1&".","."&A1&".")),".","")),"")

  5. #5
    Registered User
    Join Date
    06-30-2015
    Location
    Israel
    MS-Off Ver
    MS Office 2003, 2010, 2013
    Posts
    6

    Re: Find Exact Number from a String in cell (InStr(13,"1.2.13.4") >> gives 6 i/o 0)

    Quote Originally Posted by AliGW View Post
    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).


    Dear AliGW
    Thanks for your notice.
    corrected the post.
    I'm new here so....I'll still learning the rules....
    Have a great Day !

    Shlomi

  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,410

    Re: Find Exact Number from a String in cell (InStr(13,"1.2.13.4") >> gives 6 i/o 0)

    Thank you for adding the link. Please take a moment to read through the forum rules, to which you agreed upon joining. Thanks!

  7. #7
    Registered User
    Join Date
    06-30-2015
    Location
    Israel
    MS-Off Ver
    MS Office 2003, 2010, 2013
    Posts
    6

    Re: Find Exact Number from a String in cell (InStr(13,"1.2.13.4") >> gives 6 i/o 0)

    Thanks a lot !!
    Great ideas !

    I'm attaching a solution with VBA code that I got from this web site (maybe it will help someone):
    http://vbaf1.com/q/a/check-if-string-in-a-cell/

    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. [SOLVED] If Instr(Cells(x,1), "String") or InStr(cells(x,1),"string") Then.... won't work
    By DAKevin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-19-2016, 06:10 PM
  2. Highlight cells containing exact string value "our" and not "your" as well?
    By papazulu in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-01-2016, 02:20 AM
  3. [SOLVED] Does not cosistantly find a text string using "InStr" function
    By Bobbbo in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 03-21-2016, 08:37 PM
  4. How to use InStr function to search for a text that starts with "CTF" and ends with "."?
    By yoursamrit2000 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-27-2014, 06:52 PM
  5. Replies: 1
    Last Post: 10-08-2014, 05:56 AM
  6. [SOLVED] search for a "part number" within a string and return its cell position or contents of cel
    By benakil in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-24-2013, 06:37 AM
  7. Find id"" and replace with id"consecutive number" 3071 entries
    By RoyLittle0 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-19-2012, 07:27 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