Hallo,
folgender Code ersetzt einen Suchstring nur einmal von Rechts:
Dim Bereich As Range
Dim Zelle As Range
Set Bereich = Range(Cells(10, 2), Cells(Range("B10").End(xlDown).Row, Range("B10").End(xlToRight).Column))
For Each Zelle In Bereich
With Zelle
.value = ReplaceOneFromRight(Zelle.value, ".", ",")
End With
Next Zelle
Function ReplaceOneFromRight(Expression As String, Find As String, Replace As String)
On Error GoTo Err_Handler
Dim iPos As Integer
ReplaceOneFromRight = Expression
For iPos = Len(Expression) To 1 Step -1
If Mid(Expression, iPos, Len(Find)) = Find Then
ReplaceOneFromRight = Left(Expression, iPos - (Len(Find) - IIf(Len(Find) > 1, 1, 0))) + Replace + Right(Expression, Len(Expression) - iPos - (Len(Find) - 1))
Exit For
End If
Next
Err_Exit:
Exit Function
Err_Handler:
Resume Err_Exit
End Function
|