ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   error 438 on For statement (https://www.excelbanter.com/excel-programming/394283-error-438-statement.html)

Janis

error 438 on For statement
 
It has an object doesn't support this property and I don't see anything wrong.

Sub AddNodeCommas()
Dim SlashPos As Long
Dim myCell As Range

For Each myCell In ActiveSheet.Ranges("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

tia,

Don Guillett

error 438 on For statement
 
Range S

However, this might be a little more efficient.
Sub ifslash()
lr = Cells(Rows.Count, "d").End(xlUp).Row
For Each c In Range("d2:d" & lr)
If InStr(c, "/") < 1 And c < "" Then c.Value = c & ","
Next
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Janis" wrote in message
...
It has an object doesn't support this property and I don't see anything
wrong.

Sub AddNodeCommas()
Dim SlashPos As Long
Dim myCell As Range

For Each myCell In ActiveSheet.Ranges("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

tia,




All times are GMT +1. The time now is 02:18 AM.

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