Consulting

Results 1 to 5 of 5

Thread: Solved: Find "/" in string & debug.print ?

  1. #1

    Solved: Find "/" in string & debug.print ?

    I am trying to find cell values w/ two slashes.
    If it does, color it red.
    Secondarily, I would like to use Debug.Print to tell me which row I am in whilst telling me the value, possible?

    [vba]
    If c.Value = c.Value Like "*/*" & "*/*" Then
    c.Interior.Color = vbRed
    End If
    Debug.Print c.Value
    'Debug.Print Range(0, 0).Address
    Next c
    [/vba]

    thx....
    my site: www.ecboardco.com
    was built w/ a majority of the assistance from the board members here... thanks VBAX.

    Just because I see something, doesn't mean that what's actually happening is what I see.

    You don't get from 0-90 by standing still!

  2. #2
    Having the slashes in the middle of the term, not liking it to find it....
    I also tried this:
    If InStr(c, "*/*") > 0 Then

    an example of the term I am looping through on is:
    orange/purple/silver
    my site: www.ecboardco.com
    was built w/ a majority of the assistance from the board members here... thanks VBAX.

    Just because I see something, doesn't mean that what's actually happening is what I see.

    You don't get from 0-90 by standing still!

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Dim c As Range

    For Each c In Selection
    If Len(c.Value) - Len(Replace(c.Value, "/", "")) = 2 Then
    c.Interior.Color = vbRed
    Debug.Print c.Row
    End If
    Next c
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    Administrator
    Chat VP
    VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Quote Originally Posted by YellowLabPro
    I am trying to find cell values w/ two slashes.
    If it does, color it red.
    Secondarily, I would like to use Debug.Print to tell me which row I am in whilst telling me the value, possible?

    [vba]
    If c.Value = c.Value Like "*/*" & "*/*" Then
    c.Interior.Color = vbRed
    End If
    Debug.Print c.Value
    'Debug.Print Range(0, 0).Address
    Next c
    [/vba]

    thx....
    [VBA]
    Sub DoStuff()
    '
    Dim C As Range
    '
    For Each C In Selection
    With C
    If .Value Like "*/*/*" Then
    .Interior.Color = vbRed
    Debug.Print .Value
    Debug.Print "Row " & .Row
    End If
    End With
    Next
    '
    End Sub
    [/VBA]
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  5. #5
    Thanks Bob,
    Awesome & Perfecto!

    Thanks John,
    The text "Row " tip is really nice.

    cheers and salute-

    Doug
    my site: www.ecboardco.com
    was built w/ a majority of the assistance from the board members here... thanks VBAX.

    Just because I see something, doesn't mean that what's actually happening is what I see.

    You don't get from 0-90 by standing still!

Posting Permissions

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