ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   Macro to remove last 4 characters from the contents of a cell. (https://www.excelbanter.com/new-users-excel/139659-macro-remove-last-4-characters-contents-cell.html)

akkrug

Macro to remove last 4 characters from the contents of a cell.
 
We need to come up with a way to remove the last 4 characters from the
contents of a cell. I tried a macro, but wasn't sure how to make it go to
the next cell. For example, I select a cell, press end, backspace 4
positions and then hit enter. Works great for 1 cell! Is there a way to get
the macro to repeat all the way down the spreadsheet?

As always, Thanks for the help!

Ken
--
akkrug

Bernie Deitrick

Macro to remove last 4 characters from the contents of a cell.
 
Ken,

Select the cells and run this macro:

Sub Remove4()
Dim myCell As Range
For Each myCell In Selection
myCell.Value = Left(myCell.Value, Len(myCell.Value) - 4)
Next myCell
End Sub

HTH,
Bernie
MS Excel MVP


"akkrug" wrote in message
...
We need to come up with a way to remove the last 4 characters from the
contents of a cell. I tried a macro, but wasn't sure how to make it go to
the next cell. For example, I select a cell, press end, backspace 4
positions and then hit enter. Works great for 1 cell! Is there a way to get
the macro to repeat all the way down the spreadsheet?

As always, Thanks for the help!

Ken
--
akkrug





All times are GMT +1. The time now is 12:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com