ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I apply LTRIM to entire Sheet? (https://www.excelbanter.com/excel-programming/306595-how-do-i-apply-ltrim-entire-sheet.html)

D[_6_]

How do I apply LTRIM to entire Sheet?
 
Hey guys-
I have an entire sheet filled with data. Many columns/rows have spaces at
the beginning of the cell. Many cells have multiple words in them, so a
simple Find/Replace wont work. I need to use LTRIM across the entire
worksheet so it deletes out all the leading spaces. How can this be done
easily???
Thanks
D



david mcritchie

How do I apply LTRIM to entire Sheet?
 
Hi "D",
You would need a macro. Posting to anyone of these
groups gets read by the same people. But at least
we know you know about macros (programming).

There is an LTRIM in VBA so you can use the VBA
function. For rest of macro see
http://www.mvps.org/dmcritchie/excel/join.htm#trimall
you would want to give it a different name like LtrimAll
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"D" wrote in message news:3NfSc.26637$Oi.2989@fed1read04...
Hey guys-
I have an entire sheet filled with data. Many columns/rows have spaces at
the beginning of the cell. Many cells have multiple words in them, so a
simple Find/Replace wont work. I need to use LTRIM across the entire
worksheet so it deletes out all the leading spaces. How can this be done
easily???
Thanks
D





Soo Cheon Jheong[_2_]

How do I apply LTRIM to entire Sheet?
 
Hi,

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Sub TEST()

Dim CL As Range
Dim RNG As Range

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

On Error Resume Next
Set RNG = Cells.SpecialCells(xlConstants, xlTextValues)
For Each CL In Intersect(Selection, RNG)
CL.Value = LTrim(CL.Value)
Next
On Error GoTo 0

Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True

End Sub
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


--
Regards,
Soo Cheon Jheong
_ _
^вп^
--




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

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