+ Reply to Thread
Results 1 to 6 of 6

VBA Wildcard character / find cell which CONTAINS a text

  1. #1
    Forum Contributor
    Join Date
    08-06-2007
    Posts
    105

    VBA Wildcard character / find cell which CONTAINS a text

    I need my VB code to find cells that CONTAIN specific text, not have to be = to it. All the cells have a 4 digit code and a space before the word total.

    Please Login or Register  to view this content.
    I've tried:
    Please Login or Register  to view this content.
    ^ It doesn't error out, but doesn't work either

    I've tried to search this but can't seem to find a logical answer.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: VBA Wildcard character / find cell which CONTAINS a text

    Hi adgjqetuo

    try.....
    Please Login or Register  to view this content.
    Last edited by pike; 06-11-2009 at 11:44 PM. Reason: code tags
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Registered User
    Join Date
    05-20-2009
    Location
    NY
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: VBA Wildcard character / find cell which CONTAINS a text

    You could also use the instr function, assume data is specified as: <4 digits> <space> Total
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    08-06-2007
    Posts
    105

    Re: VBA Wildcard character / find cell which CONTAINS a text

    Thanks for the reply!

    I actually played around some and I got this to work:

    Please Login or Register  to view this content.
    I was missing the word "LIKE"

  5. #5
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: VBA Wildcard character / find cell which CONTAINS a text

    hey adgjqetuo
    Its allways the simple solution thats best.well done
    can you also please mark the post Solved?

  6. #6
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: VBA Wildcard character / find cell which CONTAINS a text

    Personally I would be tempted to modify the line of code to be:

    Please Login or Register  to view this content.
    As this will match EXACTLY what you are looking for; 4 digits, a space, "Total".

    Using your code the way it is you would also get matches for "SubTotal", and "TeeTotal" for instance.
    If you find the response helpful please click the scales in the blue bar above and rate it
    If you don't like the response, don't bother with the scales, they are not for 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