PC Review


Reply
Thread Tools Rate Thread

Delete Spaces from text download

 
 
=?Utf-8?B?TGVz?=
Guest
Posts: n/a
 
      6th Sep 2007
Hi all, i am pulling a text file into excel and the one field, e-mails, has a
lot of spaces of variable size in it, is there a way i can delete these with
code ??

Any help would be greatly appreciated...
--
Les
 
Reply With Quote
 
 
 
 
JW
Guest
Posts: n/a
 
      6th Sep 2007
To get rid of leading and trailing spaces:
Range("A1").Value=Trim(Range("A1").Value

To get rid of all spaces:
Range("A1").Value = Replace(Range("A1").Value, " ", "")

Les wrote:
> Hi all, i am pulling a text file into excel and the one field, e-mails, has a
> lot of spaces of variable size in it, is there a way i can delete these with
> code ??
>
> Any help would be greatly appreciated...
> --
> Les


 
Reply With Quote
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      6th Sep 2007
Select the cells and run:

Sub spacekiller()
For Each r In Selection
r.Value = Replace(r.Value, " ", "")
Next
End Sub



--
Gary''s Student - gsnu200743


"Les" wrote:

> Hi all, i am pulling a text file into excel and the one field, e-mails, has a
> lot of spaces of variable size in it, is there a way i can delete these with
> code ??
>
> Any help would be greatly appreciated...
> --
> Les

 
Reply With Quote
 
=?Utf-8?B?TGVz?=
Guest
Posts: n/a
 
      6th Sep 2007
Thanks A million Gary"s Student, works great... :-0)
--
Les


"Gary''s Student" wrote:

> Select the cells and run:
>
> Sub spacekiller()
> For Each r In Selection
> r.Value = Replace(r.Value, " ", "")
> Next
> End Sub
>
>
>
> --
> Gary''s Student - gsnu200743
>
>
> "Les" wrote:
>
> > Hi all, i am pulling a text file into excel and the one field, e-mails, has a
> > lot of spaces of variable size in it, is there a way i can delete these with
> > code ??
> >
> > Any help would be greatly appreciated...
> > --
> > Les

 
Reply With Quote
 
Yossy
Guest
Posts: n/a
 
      14th May 2008
Hi Gary I tried to use your space killer code to trim but gave error. am i
doing something wrong? This error Complile error. Variable not defined and it
highlighted the r and the sub spacekiller.

Will appreciate your help. Thanks

"Gary''s Student" wrote:

> Select the cells and run:
>
> Sub spacekiller()
> For Each r In Selection
> r.Value = Replace(r.Value, " ", "")
> Next
> End Sub
>
>
>
> --
> Gary''s Student - gsnu200743
>
>
> "Les" wrote:
>
> > Hi all, i am pulling a text file into excel and the one field, e-mails, has a
> > lot of spaces of variable size in it, is there a way i can delete these with
> > code ??
> >
> > Any help would be greatly appreciated...
> > --
> > Les

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      14th May 2008
Good... that means your are using Option Explicit in your procedure modules.
The Option Explicit statement requires all variables to be declared (really
helpful when you accidentally misspell a declared variable name later on in
your code) and 'r' is a variable that was not declared. Add this as the
first statement in the subroutine and all should be well...

Dim r As Range

Rick



"Yossy" <(E-Mail Removed)> wrote in message
news:490B33F7-3E94-498E-8E42-(E-Mail Removed)...
> Hi Gary I tried to use your space killer code to trim but gave error. am i
> doing something wrong? This error Complile error. Variable not defined and
> it
> highlighted the r and the sub spacekiller.
>
> Will appreciate your help. Thanks
>
> "Gary''s Student" wrote:
>
>> Select the cells and run:
>>
>> Sub spacekiller()
>> For Each r In Selection
>> r.Value = Replace(r.Value, " ", "")
>> Next
>> End Sub
>>
>>
>>
>> --
>> Gary''s Student - gsnu200743
>>
>>
>> "Les" wrote:
>>
>> > Hi all, i am pulling a text file into excel and the one field, e-mails,
>> > has a
>> > lot of spaces of variable size in it, is there a way i can delete these
>> > with
>> > code ??
>> >
>> > Any help would be greatly appreciated...
>> > --
>> > Les


 
Reply With Quote
 
Yossy
Guest
Posts: n/a
 
      14th May 2008
u are awesome!!!! thanks it works and also for quick response
"Rick Rothstein (MVP - VB)" wrote:

> Good... that means your are using Option Explicit in your procedure modules.
> The Option Explicit statement requires all variables to be declared (really
> helpful when you accidentally misspell a declared variable name later on in
> your code) and 'r' is a variable that was not declared. Add this as the
> first statement in the subroutine and all should be well...
>
> Dim r As Range
>
> Rick
>
>
>
> "Yossy" <(E-Mail Removed)> wrote in message
> news:490B33F7-3E94-498E-8E42-(E-Mail Removed)...
> > Hi Gary I tried to use your space killer code to trim but gave error. am i
> > doing something wrong? This error Complile error. Variable not defined and
> > it
> > highlighted the r and the sub spacekiller.
> >
> > Will appreciate your help. Thanks
> >
> > "Gary''s Student" wrote:
> >
> >> Select the cells and run:
> >>
> >> Sub spacekiller()
> >> For Each r In Selection
> >> r.Value = Replace(r.Value, " ", "")
> >> Next
> >> End Sub
> >>
> >>
> >>
> >> --
> >> Gary''s Student - gsnu200743
> >>
> >>
> >> "Les" wrote:
> >>
> >> > Hi all, i am pulling a text file into excel and the one field, e-mails,
> >> > has a
> >> > lot of spaces of variable size in it, is there a way i can delete these
> >> > with
> >> > code ??
> >> >
> >> > Any help would be greatly appreciated...
> >> > --
> >> > Les

>
>

 
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
How do I delete spaces from the end of text =?Utf-8?B?R2Vvcmdl?= Microsoft Excel Misc 4 11th Sep 2006 07:33 AM
How do I delete spaces in between text? Trim doesnt work. =?Utf-8?B?Q2hhcnUgUmFtYWtyaXNobmFu?= Microsoft Access Queries 2 6th Sep 2006 08:44 PM
Delete empty spaces at the end of text of a column? nbaj2k Microsoft Excel Programming 1 8th Aug 2006 02:47 PM
Cannot delete text/spaces =?Utf-8?B?WmVyZXR1bDE=?= Microsoft Word Document Management 3 12th Oct 2005 11:01 PM
Delete Spaces and Join Text in Cell =?Utf-8?B?RGlnZ3N5?= Microsoft Excel Worksheet Functions 3 5th Oct 2005 03:50 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:17 PM.