+ Reply to Thread
Results 1 to 6 of 6

problem finding string using .find method when string to be found contains ~ (a tilde)

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    problem finding string using .find method when string to be found contains ~ (a tilde)

    hi,

    I am enclosing a macro. This macro basically looks in the first column for the string located in cell (row 2 column 1). But because this cell contains a "~".........(i think) the find method does not find it..........am i doing something wrong?

    Also, how to get this to work?
    Attached Files Attached Files

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: problem finding string using .find method when string to be found contains ~ (a tilde)

    Please Login or Register  to view this content.



  3. #3
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: problem finding string using .find method when string to be found contains ~ (a tilde)

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    oops.. snb already there..

    BTW same rule is applied for "*" also...
    Regards!
    =DEC2HEX(3563)

    If you like someone's answer, click the star to give them a reputation point for that answer...

  4. #4
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: problem finding string using .find method when string to be found contains ~ (a tilde)

    i tried it and it worked.............so thanks!!!!!!!!!!!!!!

    But i dont understand why this worked.............is there a simple explanation?

  5. #5
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: problem finding string using .find method when string to be found contains ~ (a tilde)

    Microsoft Excel uses the tilde (~) as a marker to indicate that the next character is a literal. When you use the Find and Replace dialog box to find or replace a character such as a tilde (~), an asterisk (*), or a question mark (?), you must add a tilde (~) before the character in the Find what box.
    from : http://support.microsoft.com/kb/214138

  6. #6
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: problem finding string using .find method when string to be found contains ~ (a tilde)

    exactly the explanation i was looking for

    thanks to both of you!

+ 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