View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default VBA help please - remove leading spaces

dim myCell as range
for each mycell in selection.cells
mycell.formula = ltrim(mycell.formula)
next mycell




Scott Wagner wrote:

In column D of my worksheet some of the cell contents have a varying number
of spaces. How can I removed any leading spaces from those cells with VBA?

There are spaces within the cells (not leading) that I want to keep.

Example below.

Here is what I have now:

ColD
This is the text
Blah Blah Blah
Blah Blah Blah Blah
This is the text

Here is what I'd like to end up with:

ColD
This is the text
Blah Blah Blah
Blah Blah Blah Blah
This is the text

Thanks in advance!

Scott


--

Dave Peterson