Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default leading and ending space

i need to create a macro that will remove leading and ending extra spaces
without disturbing a leading "0" of a number in a cell eg. 03222 should
remain the same n not 3222
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default leading and ending space

use TRIM
"scharee" wrote in message
...
i need to create a macro that will remove leading and ending extra spaces
without disturbing a leading "0" of a number in a cell eg. 03222 should
remain the same n not 3222



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default leading and ending space

Try the below and feedback..

Sub Macro()
Dim cell As Range
For Each cell In ActiveSheet.UsedRange
If Not cell.HasFormula Then cell.Value = Trim(cell.Text)
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"scharee" wrote:

i need to create a macro that will remove leading and ending extra spaces
without disturbing a leading "0" of a number in a cell eg. 03222 should
remain the same n not 3222

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
Removing leading and trailing space... Jeffery B Paarsa Excel Discussion (Misc queries) 2 October 8th 09 11:43 PM
Excel - How do I keep an ending space in a cell? i.e. "Mr. " jme123 Excel Discussion (Misc queries) 1 April 7th 09 03:02 AM
how do I delete a leading space in a whole lot of cells? [email protected] Excel Discussion (Misc queries) 4 August 4th 07 03:24 AM
Remove leading space Karidre Excel Worksheet Functions 4 October 24th 05 03:39 PM
Paper Space / Model Space ? Coolboy55 Excel Discussion (Misc queries) 0 September 1st 05 08:58 PM


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

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"