MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Removing a Set Number of Characters From a Cell


November 11, 2001 - by Bill Jelen

Lloyd writes:

I attempted to use the F2/Edit function in the record macro mode. It would not work. It appears when you are in the F2 mode, record is turned off. Is this true? What I need to do throughout a big worksheet was to edit the cell, move the cursor to the end of the cell and then delete the last 4 characters if the characters.
This macro should do it:

Sub RemoveLast4()
    For Each cell In ActiveSheet.Cells.SpecialCells(xlCellTypeConstants)
        cell.Value = Left(cell.Value, Len(cell.Value) - 4)
    Next cell
End Sub