PC Review


Reply
Thread Tools Rate Thread

Delete Variable spaces at beginning of a range

 
 
gmunro
Guest
Posts: n/a
 
      21st Aug 2007
Hi,

I pull a report from a source I don't control.
The report has a list starting in cell B27 and is of variable length.

The problem I have is the programmers who I cannot influence, change
the number of spaces at the beginning of the list, and I use this
report for a vlookup, so exact match is required

They went from 15 spaces before teh data to none to 14.

How can I count the number of spaces and replace with "" in a specific
range?

Any help is appreciated

Glen

 
Reply With Quote
 
 
 
 
JW
Guest
Posts: n/a
 
      21st Aug 2007
Any other spaces in the cell? If not, you can use a substitute
formula to replace all empty spaces with nothing.
=SUBSTITUTE(C4," ","")
To get rid of all of the spaces except those separating words, use a
trim formula
=TRIM(C4)

HTH
-Jeff-

gmunro wrote:
> Hi,
>
> I pull a report from a source I don't control.
> The report has a list starting in cell B27 and is of variable length.
>
> The problem I have is the programmers who I cannot influence, change
> the number of spaces at the beginning of the list, and I use this
> report for a vlookup, so exact match is required
>
> They went from 15 spaces before teh data to none to 14.
>
> How can I count the number of spaces and replace with "" in a specific
> range?
>
> Any help is appreciated
>
> Glen


 
Reply With Quote
 
gmunro
Guest
Posts: n/a
 
      21st Aug 2007
On Aug 21, 9:54 am, JW <JWRIGH...@triad.rr.com> wrote:
> Any other spaces in the cell? If not, you can use a substitute
> formula to replace all empty spaces with nothing.
> =SUBSTITUTE(C4," ","")
> To get rid of all of the spaces except those separating words, use a
> trim formula
> =TRIM(C4)
>
> HTH
> -Jeff-
>
>
>
> gmunro wrote:
> > Hi,

>
> > I pull a report from a source I don't control.
> > The report has a list starting in cell B27 and is of variable length.

>
> > The problem I have is the programmers who I cannot influence, change
> > the number of spaces at the beginning of the list, and I use this
> > report for a vlookup, so exact match is required

>
> > They went from 15 spaces before teh data to none to 14.

>
> > How can I count the number of spaces and replace with "" in a specific
> > range?

>
> > Any help is appreciated

>
> > Glen- Hide quoted text -

>
> - Show quoted text -


Can you trim a selected range? or do you need to use the trim function
in a separate column and then copy/paste your data?

 
Reply With Quote
 
JW
Guest
Posts: n/a
 
      21st Aug 2007
The Trim formula would be in a separate cell. You could use VBA to
loop through the range and Trim the cells though. Something like:
sub untested()
Dim cl as Range, clRange as Range
Set clRange=Range("A2:A50")
For Each cl in clRange
cl.Value=Trim(cl.Value)
Next cl
Set clRange=Nothing
End Sub

gmunro wrote:
> On Aug 21, 9:54 am, JW <JWRIGH...@triad.rr.com> wrote:
> > Any other spaces in the cell? If not, you can use a substitute
> > formula to replace all empty spaces with nothing.
> > =SUBSTITUTE(C4," ","")
> > To get rid of all of the spaces except those separating words, use a
> > trim formula
> > =TRIM(C4)
> >
> > HTH
> > -Jeff-
> >
> >
> >
> > gmunro wrote:
> > > Hi,

> >
> > > I pull a report from a source I don't control.
> > > The report has a list starting in cell B27 and is of variable length.

> >
> > > The problem I have is the programmers who I cannot influence, change
> > > the number of spaces at the beginning of the list, and I use this
> > > report for a vlookup, so exact match is required

> >
> > > They went from 15 spaces before teh data to none to 14.

> >
> > > How can I count the number of spaces and replace with "" in a specific
> > > range?

> >
> > > Any help is appreciated

> >
> > > Glen- Hide quoted text -

> >
> > - Show quoted text -

>
> Can you trim a selected range? or do you need to use the trim function
> in a separate column and then copy/paste your data?


 
Reply With Quote
 
Ron Rosenfeld
Guest
Posts: n/a
 
      21st Aug 2007
On Tue, 21 Aug 2007 05:35:11 -0700, gmunro <(E-Mail Removed)> wrote:

>Hi,
>
>I pull a report from a source I don't control.
>The report has a list starting in cell B27 and is of variable length.
>
>The problem I have is the programmers who I cannot influence, change
>the number of spaces at the beginning of the list, and I use this
>report for a vlookup, so exact match is required
>
>They went from 15 spaces before teh data to none to 14.
>
>How can I count the number of spaces and replace with "" in a specific
>range?
>
>Any help is appreciated
>
>Glen


In Excel you can use the TRIM function to remove both leading and trailing
spaces as well as extra (more than one sequential) spaces within the text.

In VBA you can use the LTrim function to remove only leading spaces.


--ron
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Test variable range for 'Delete'; then delete the row ryguy7272 Microsoft Excel Programming 2 18th May 2010 04:41 PM
delete all spaces in range J.W. Aldridge Microsoft Excel Programming 6 13th Feb 2010 02:11 AM
Delete variable range when cell is emtpy James C. Microsoft Excel Programming 8 2nd Apr 2008 07:38 PM
Spaces at Beginning of Data Ro Pam Microsoft Word Document Management 10 7th Feb 2005 08:03 PM
Delete all Rows in a Variable Range John Microsoft Excel Programming 3 30th Jun 2004 06:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:13 PM.