ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   leading and ending space (https://www.excelbanter.com/excel-worksheet-functions/245033-leading-ending-space.html)

scharee

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

Meebers[_3_]

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




Jacob Skaria

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



All times are GMT +1. The time now is 03:32 PM.

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