ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   searching for slashes "/" in cells (https://www.excelbanter.com/excel-programming/394234-searching-slashes-cells.html)

Janis

searching for slashes "/" in cells
 
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

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:

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


All times are GMT +1. The time now is 04:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com