title: Check if a string ends with a specific character and remove it - error "invalid identifier"
body: <p>I have a VBA script which should check if the cell values in a range end with ",". If so, the comma is removed. </p>
  
  <pre><code>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
  </code></pre>
  
  <p>However, in the line</p>
  
  <pre><code> If str.EndsWith(",") Then
  </code></pre>
  
  <p>I get the errror-message "invalid identifier". But I can't find the fault in my script.
  Thank you so much for your help!</p>