+ Reply to Thread
Results 1 to 5 of 5

match entire string

  1. #1
    Registered User
    Join Date
    12-23-2008
    Location
    USA
    Posts
    60

    match entire string

    I am trying to use cells.find to find a cell containing "Date". However, it also finds cells with "Start Date" and "End Date" and any other instance of the word date. Is there anyway to make it match ONLY IF the cell contains EXACTLY "Date" and nothing else?

    Thanks,
    Dave
    Last edited by daviddoria; 12-28-2008 at 09:22 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Dave,

    The Find method of a range object has a argument that controls whether the search looks for a partial match or complete match - LookAt. The constants are xlPart and xlWhole. Also, there is an argument to control if the search is case sensitive - MatchCase. Set this to true if the search is to be case sensitive.

    Example - Whole word only, not case sensitive
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    12-23-2008
    Location
    USA
    Posts
    60
    great thanks!

  4. #4
    Registered User
    Join Date
    11-26-2008
    Location
    New England
    MS-Off Ver
    2007
    Posts
    35

    How can I use the result of a FIND in an if statement?

    I'm working on something like daviddoria's problem, only I want to use the result to trigger an If..Then to run or be bypassed.

    I plugged the code Leith Ross posted into my file top see what the output is, and it returned "DATE" into a random cell I assigned it to.

    I adjusted the code to address my situation. Whne I run the macro on a sheet with "Rev 2" (which doesn't need to go thru the routine), I'm getting Error 91("Object variable or With block variable not set "). When I run a sheet with "Rev 1", it runs without a hitch.

    Please Login or Register  to view this content.
    Last edited by TedH; 12-30-2008 at 11:34 AM.

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello TedH,

    Please start a new thread.


    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.

    Sincerely,
    Leith Ross

+ 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