I have a VBA script which should check if the cell values in a range end with ",". If so, the comma is removed.
Dim Bereich As Range
Dim Zeilen As Long
Dim Zelle As Range
Dim str As String
Zeilen = Cells(Rows.Count, 1).End(xlUp).Row
Set Bereich = Range(Cells(4, 3), Cells(Zeilen, 19))
For Each Zelle In Bereich
str = Zelle.Value
If str.EndsWith(",") Then
str = Left(str, Len(str) - 1)
Zelle.Value = str
End If
Next Zelle
However, in the line
If str.EndsWith(",") Then
I get the errror-message "invalid identifier". But I can't find the fault in my script. Thank you so much for your help!