Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Rick
 
Posts: n/a
Default 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?
  #2   Report Post  
Norman Jones
 
Posts: n/a
Default

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?



  #3   Report Post  
Norman Jones
 
Posts: n/a
Default

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?





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
in cell editing macro ynissel Excel Discussion (Misc queries) 2 July 27th 05 08:28 PM
macro help thephoenix12 Excel Discussion (Misc queries) 4 July 15th 05 06:57 PM
converting Lotus 123 macro to Excell macro mark h Excel Discussion (Misc queries) 6 July 11th 05 02:28 PM
Relative Cell position NOT working with or without macro Scratching my Head Excel Discussion (Misc queries) 6 May 30th 05 07:12 PM
Copy cell format to cell on another worksht and update automatical kevinm Excel Worksheet Functions 21 May 19th 05 12:07 PM


All times are GMT +1. The time now is 02:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"