+ Reply to Thread
Results 1 to 4 of 4

How to meet conditions with wildcards...

  1. #1
    Registered User
    Join Date
    11-04-2010
    Location
    Ottawa, Ontario, Canada
    MS-Off Ver
    Excel 2002
    Posts
    13

    How to meet conditions with wildcards...

    Hi everyone,

    I'm trying to come up with a simple condition for a "String" value (Well, it's really in a Range but...).

    My condition would starts with Activities but wildcard after at then end ( i.e. "Activities*" ) and this argument works fine with say .Find but doesn't seem to work in a condition.

    My Sheet kind'of looks like: (sorry for the lame example)

    ItemName...........Value 1..........Value 2
    ActivitiesOne......1.....................5
    ActivitiesTwo......2.....................4
    ActivitiesThree...4.....................9
    ProductOne........1.....................1
    ProductTwo........2.....................3
    ProductThree.....4....................10
    Other123.............1.....................2
    Other456.............3.....................2
    Other788.............45...................233
    etc...

    My Code

    ' I've got a bunch of code before/after (it's in a loop) but my problem is this condition:
    ' Nota: rng is a Range (but rng shows the first column, which is String)

    If rng = "Activities*" Or rng = "Product*" Then
    'Do This
    Else
    'Do That
    End If

    ' While debuggin, I've noticed that my wildcard * just isn't working. Any suggestions?

    Thanks..

    Alex
    Last edited by CEC; 01-13-2011 at 12:15 PM.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: How to meet conditions with wildcards...

    You could have a look at using the Like Operator and maybe the Select Case Statement.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: How to meet conditions with wildcards...

    Perhaps something like this...

    Please Login or Register  to view this content.
    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  4. #4
    Registered User
    Join Date
    11-04-2010
    Location
    Ottawa, Ontario, Canada
    MS-Off Ver
    Excel 2002
    Posts
    13

    Re: How to meet conditions with wildcards...

    Thanks to both of you (Domski and Ron) for your replies.

    Ron, I worked out your code and used your method and the wildcard worked!

    Thanks much. You guys rock.

    Alex

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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