Board index » Excel » searching for slashes "/" in cells

searching for slashes "/" in cells

Excel132
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,


-
 

Re:searching for slashes "/" in cells

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









Janis wrote:

Quote


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,



--



Dave Peterson

-