Hi, I am using the below code to remove letters from the left side of a string. The code does it's job and delete 4 characters, but after that it stops with the error message: Run-time error "5" Invalid procedure call or argument. What is causing this to happen?
Sub RemoveLefts()
Dim cell As Range
Dim MyRange As Range
Dim tmp As String
Set MyRange = Sheet1.Columns(5)
For Each cell In MyRange.Cells
tmp = cell.Value
'output n - 1 characters from the right
cell.Value = Right(tmp, Len(tmp) - 4)
Next
End Sub
Sub RemoveLefts()
Dim cell As Range
Dim MyRange As Range
Dim tmp As String
Set MyRange = Sheet1.Columns(5)
For Each cell In MyRange.Cells
tmp = cell.Value
'output n - 1 characters from the right
cell.Value = Right(tmp, Len(tmp) - 4)
Next
End Sub