![]() |
set up a macro to delete characters in each cell of a column
I wish to delete 3 characters in each cell of a row. A macro qould be much
faster but how i do it? |
Hi Rick,
Try: '=================== Public SubDeleteLast3Chars() Dim rng As Range Dim rcell As Range Dim WB As Workbook Dim SH As Worksheet Dim iLen As Long Set WB = ActiveWorkbook '<<========== CHANGE Set SH = WB.Sheets("Sheet4") '<<========== CHANGE Set rng = SH.Range("A2:M2") '<<========== CHANGE For Each rcell In rng.Cells With rcell If Not .HasFormula Then If Not IsEmpty(.Value) Then iLen = Len(.Value) .Value = Left(.Value, iLen - 3) End If End If End With Next End Sub '<<=================== --- Regards, Norman "Rick" wrote in message ... I wish to delete 3 characters in each cell of a row. A macro qould be much faster but how i do it? |
Hi Rick,
Public SubDeleteLast3Chars() should read: Public Sub DeleteLast3Chars() (To rectify dropped space!) --- Regards, Norman "Norman Jones" wrote in message ... Hi Rick, Try: '=================== Public SubDeleteLast3Chars() Dim rng As Range Dim rcell As Range Dim WB As Workbook Dim SH As Worksheet Dim iLen As Long Set WB = ActiveWorkbook '<<========== CHANGE Set SH = WB.Sheets("Sheet4") '<<========== CHANGE Set rng = SH.Range("A2:M2") '<<========== CHANGE For Each rcell In rng.Cells With rcell If Not .HasFormula Then If Not IsEmpty(.Value) Then iLen = Len(.Value) .Value = Left(.Value, iLen - 3) End If End If End With Next End Sub '<<=================== --- Regards, Norman "Rick" wrote in message ... I wish to delete 3 characters in each cell of a row. A macro qould be much faster but how i do it? |
All times are GMT +1. The time now is 02:08 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com