Results 1 to 3 of 3

Regular Expression to Return "True" or False" if a word is found

Threaded View

  1. #1
    Registered User
    Join Date
    01-26-2015
    Location
    Massachusetts
    MS-Off Ver
    2016
    Posts
    73

    Regular Expression to Return "True" or False" if a word is found

    Hello,

    I've been using regular expression in several custom functions to check and correct various things with addresses. I'd like to create one more function that simply returns True or False in the adjacent cell if the cell with the address contains one of several words. One of the problems will be c/o for "care of". It could be anywhere on the line. Not sure how to escape the back slash either.

        Function CHECKADDRESS(strLookIn As String) As String
        Dim objRegEx
      
        Set objRegEx = CreateObject("VBScript.RegExp")
        objRegEx.Global = True
        objRegEx.IgnoreCase = False
        
        CHECKADDRESS = strLookIn
        objRegEx.Pattern = "\bStreet\b"
        CHECKADDRESS = ("True")
    
        CHECKADDRESS = strLookIn
        objRegEx.Pattern = "\bc/o\b"
        CHECKADDRESS = ("False")
    
    End Function
    Thank you for your help.

    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time. --6StringJazzer
    Last edited by 6StringJazzer; 03-02-2017 at 04:57 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Check next row if value is, "FALSE," if "TRUE," return specified value from this row
    By Dave_Doodle in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-19-2015, 10:18 AM
  2. How can I get a value to return "Y" OR "N" instead of true or false
    By bunnyfrostr in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-04-2014, 05:44 PM
  3. [SOLVED] How to Count number of "Error" and "OK" after the word "Instrument" found in table row
    By eltonlaw in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2012, 06:26 AM
  4. VLookup to return "true" or "false"
    By Sph01 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-29-2011, 11:10 AM
  5. Replies: 5
    Last Post: 10-12-2010, 06:46 AM
  6. Replies: 7
    Last Post: 05-13-2006, 05:02 PM
  7. [SOLVED] IF(VLOOKUP("MYDATA", MYNAME, 4) = 0, "TRUE", "FALSE")
    By Souris in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-17-2005, 01:05 AM

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