Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel Macro to edit and delete one character in a cell

Can anyone please help.

I am trying to write a very simple macro that will just edit a cell and
delete the last chracter.
Example:
I have a column with the following numbers:
1234
5678
9032

I want a macro that I can just convert each cell to the following:
123
567
903

Therefore, stripping the last digit. I don't even mind if it splits the cell
into two so the end result is:
123 4
567 8
903 2

Thank,
David


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Excel Macro to edit and delete one character in a cell

You sure you want to do this by macro?
The formula
=LEFT(A1,LEN(A1)-1)
or similar will do this (may have to introduce some error trapping IF
statement to cater for LEN(A1) being fewer than 2 characters long).
If you only have to do it as a one-off exercise, you could create a column
of the above and copy down, then copy the column and pastespecial Values
into where you want it to go, then delete the formula column.


"David" wrote in message
...
Can anyone please help.

I am trying to write a very simple macro that will just edit a cell and
delete the last chracter.
Example:
I have a column with the following numbers:
1234
5678
9032

I want a macro that I can just convert each cell to the following:
123
567
903

Therefore, stripping the last digit. I don't even mind if it splits the

cell
into two so the end result is:
123 4
567 8
903 2

Thank,
David




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Excel Macro to edit and delete one character in a cell

Hi David

Select the cells and run this:

Sub DelLast()
Dim Cel As Range
For Each Cel In Selection
If Cel.HasFormula = False Then
If Len(Cel.Value) 1 Then _
Cel.Value = _
Left(Cel.Value, Len(Cel.Value) - 1)
End If
Next
End Sub

HTH. Best wishes Harald

"David" skrev i melding
...
Can anyone please help.

I am trying to write a very simple macro that will just edit a cell and
delete the last chracter.
Example:
I have a column with the following numbers:
1234
5678
9032

I want a macro that I can just convert each cell to the following:
123
567
903

Therefore, stripping the last digit. I don't even mind if it splits the

cell
into two so the end result is:
123 4
567 8
903 2

Thank,
David




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Excel Macro to edit and delete one character in a cell

or maybe =INT(A1/10)

--
HTH

-------

Bob Phillips
"Jack Sheet" wrote in message
...
You sure you want to do this by macro?
The formula
=LEFT(A1,LEN(A1)-1)
or similar will do this (may have to introduce some error trapping IF
statement to cater for LEN(A1) being fewer than 2 characters long).
If you only have to do it as a one-off exercise, you could create a column
of the above and copy down, then copy the column and pastespecial Values
into where you want it to go, then delete the formula column.


"David" wrote in message
...
Can anyone please help.

I am trying to write a very simple macro that will just edit a cell and
delete the last chracter.
Example:
I have a column with the following numbers:
1234
5678
9032

I want a macro that I can just convert each cell to the following:
123
567
903

Therefore, stripping the last digit. I don't even mind if it splits the

cell
into two so the end result is:
123 4
567 8
903 2

Thank,
David






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Excel Macro to edit and delete one character in a cell


Assuming the number is in Cell A1, in Sheet1:

Sub delLastFellow()
Dim myString As String

myString = Worksheets("Sheet1").Range("A1").Value

myString = Left(myString, Len(myString) - 1)

Range("A1").Value = myString
End Sub


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel Macro to edit and delete one character in a cell

Brilliant. Works great. Thanks.

"Harald Staff" wrote in message
...
Hi David

Select the cells and run this:

Sub DelLast()
Dim Cel As Range
For Each Cel In Selection
If Cel.HasFormula = False Then
If Len(Cel.Value) 1 Then _
Cel.Value = _
Left(Cel.Value, Len(Cel.Value) - 1)
End If
Next
End Sub

HTH. Best wishes Harald

"David" skrev i melding
...
Can anyone please help.

I am trying to write a very simple macro that will just edit a cell and
delete the last chracter.
Example:
I have a column with the following numbers:
1234
5678
9032

I want a macro that I can just convert each cell to the following:
123
567
903

Therefore, stripping the last digit. I don't even mind if it splits the

cell
into two so the end result is:
123 4
567 8
903 2

Thank,
David






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
Challenge - Excel Line Feed Character CHR(10) - How to Delete and keep the text formatting without going ro single line in a cell ? No Name Excel Worksheet Functions 7 October 7th 09 11:10 AM
how to select the first character in a cell and delete the rest Helenf Excel Worksheet Functions 4 May 14th 09 12:10 PM
macro to copy and edit then delete a worksheet lschuh Excel Discussion (Misc queries) 13 July 27th 05 09:02 PM
Delete Asc(10) character from cell Rocky McKinley Excel Programming 7 June 12th 04 03:21 PM
How to run my macro on Insert-Rows , Edit-Delete Von Shean Excel Programming 0 January 21st 04 12:46 PM


All times are GMT +1. The time now is 09:05 PM.

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

About Us

"It's about Microsoft Excel"