searching for slashes "/" in cells

G

Guest

I need someone to fill in the blanks:

Sub AddNodeCommas()

For each C in Intersect Range("D2:D122")
if c =*"/"
substitute(c,c,c&",")
Else

Next
End Sub

What I want to do is add a comma to the end of the text in the cells if the
cell does not contain a / (forward slash). I got a syntax error in here.
this time I didn't forget the "'s

tia,
 
D

Dave Peterson

Maybe...


Option Explicit
Sub AddNodeCommas2()

Dim SlashPos As Long
Dim myCell As Range

For Each myCell In ActiveSheet.Range("d2:d122").Cells
If myCell.Value = "" Then
'skip it???
Else
SlashPos = InStr(1, myCell.Value, "/", vbTextCompare)
If SlashPos > 0 Then
'/ was found, so skip it
Else
myCell.Value = myCell.Value & ","
End If
End If
Next myCell

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top