Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: If then using a wildcard to search for text

  1. #1
    New Member
    Join Date
    Feb 2002
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I am needing to loop through a series of cells and search for a criteria. The criteria could be something like 'C172' and I want to add that whole row to a range if the cell contains even just the 'C' part or just the '1' part etc. Is there a way to do a wildcard search in vba like
    If Range("A:1").Value = "C*" so that I can do something if the value of the cell starts with 'C'?

    [ This Message was edited by: fly2079 on 2002-02-19 07:56 ]

  2. #2
    MrExcel MVP Barrie Davidson's Avatar
    Join Date
    Feb 2002
    Location
    Winnipeg
    Posts
    2,330
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-02-19 07:55, fly2079 wrote:
    I am needing to loop through a series of cells and search for a criteria. The criteria could be something like 'C172' and I want to add that whole row to a range if the cell contains even just the 'C' part or just the '1' part etc. Is there a way to do a wildcard search in vba like
    If Range("A:1").Value = "C*" so that I can do something if the value of the cell starts with 'C'?

    [ This Message was edited by: fly2079 on 2002-02-19 07:56 ]
    You can try this:
    Code:
    If UCase(Left(Range("A1").Value, 1)) = "C" Then 'rest of your code
    Note, this will work regardless of the case of the letter (i.e., "C" or "c") but you will get an error if A1 is numeric.

    Barrie Davidson

    "You're only given a little spark of madness. You mustn't lose it." - Robin Williams

  3. #3
    New Member
    Join Date
    Feb 2002
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Ok, now what do I do if I want to search for the numeral 1 or 7 or 172. What this I'm using this for is the user inputs values into a box and I want to have the option of searching for 'contains' in other words search for through and find if part of the value is in the cell. Is this a UDF?

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •