PC Review


Reply
Thread Tools Rate Thread

delete empty space after certain characters

 
 
Don Doan
Guest
Posts: n/a
 
      13th Feb 2008
Hi,
Just a quick question.
I have column D that always contained 4 letter characters. However, some of
the cells in that colum would have empty spaces following those characters.
For example, i can have something like this: "CYOD " or "DYED ".
How can i write a macro that would eliminate all the empty spaces after the
first 4 letters??

Thanks
 
Reply With Quote
 
 
 
 
Niek Otten
Guest
Posts: n/a
 
      13th Feb 2008
Insert a column to the right of D (if there isn't an empty one yet)
In( the new) E1, enter:

=LEFT(D1,4)

Copy down as far as you need.

You can use this column in your successive formulas, or you can replace the original column D with this new one:

Select column E
Edit>Copy
Select D1
Edit>Paste Special, check Values
You can now delete column E

Make a copy of your workbook before trying this

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Don Doan" <(E-Mail Removed)> wrote in message news:AE382C5D-99E0-4A77-B605-(E-Mail Removed)...
| Hi,
| Just a quick question.
| I have column D that always contained 4 letter characters. However, some of
| the cells in that colum would have empty spaces following those characters.
| For example, i can have something like this: "CYOD " or "DYED ".
| How can i write a macro that would eliminate all the empty spaces after the
| first 4 letters??
|
| Thanks


 
Reply With Quote
 
Don Doan
Guest
Posts: n/a
 
      13th Feb 2008
oh thanks.. that's simple enough...
but would it possible to create a macro to look at every row in column D and
keep the first four letters and removed the rest??

"Niek Otten" wrote:

> Insert a column to the right of D (if there isn't an empty one yet)
> In( the new) E1, enter:
>
> =LEFT(D1,4)
>
> Copy down as far as you need.
>
> You can use this column in your successive formulas, or you can replace the original column D with this new one:
>
> Select column E
> Edit>Copy
> Select D1
> Edit>Paste Special, check Values
> You can now delete column E
>
> Make a copy of your workbook before trying this
>
> --
> Kind regards,
>
> Niek Otten
> Microsoft MVP - Excel
>
> "Don Doan" <(E-Mail Removed)> wrote in message news:AE382C5D-99E0-4A77-B605-(E-Mail Removed)...
> | Hi,
> | Just a quick question.
> | I have column D that always contained 4 letter characters. However, some of
> | the cells in that colum would have empty spaces following those characters.
> | For example, i can have something like this: "CYOD " or "DYED ".
> | How can i write a macro that would eliminate all the empty spaces after the
> | first 4 letters??
> |
> | Thanks
>
>
>

 
Reply With Quote
 
Otto Moehrbach
Guest
Posts: n/a
 
      13th Feb 2008
Sub ClearSpaces()
Dim RngD As Range
Dim i As Range
Set RngD = Range("D2", Range("D" & Rows.Count).End(xlUp))
For Each i In RngD
i.Value = RTrim(i.Value)
Next i
End Sub
"Don Doan" <(E-Mail Removed)> wrote in message
news:F896693D-F1B8-4AC8-B9A6-(E-Mail Removed)...
> oh thanks.. that's simple enough...
> but would it possible to create a macro to look at every row in column D
> and
> keep the first four letters and removed the rest??
>
> "Niek Otten" wrote:
>
>> Insert a column to the right of D (if there isn't an empty one yet)
>> In( the new) E1, enter:
>>
>> =LEFT(D1,4)
>>
>> Copy down as far as you need.
>>
>> You can use this column in your successive formulas, or you can replace
>> the original column D with this new one:
>>
>> Select column E
>> Edit>Copy
>> Select D1
>> Edit>Paste Special, check Values
>> You can now delete column E
>>
>> Make a copy of your workbook before trying this
>>
>> --
>> Kind regards,
>>
>> Niek Otten
>> Microsoft MVP - Excel
>>
>> "Don Doan" <(E-Mail Removed)> wrote in message
>> news:AE382C5D-99E0-4A77-B605-(E-Mail Removed)...
>> | Hi,
>> | Just a quick question.
>> | I have column D that always contained 4 letter characters. However,
>> some of
>> | the cells in that colum would have empty spaces following those
>> characters.
>> | For example, i can have something like this: "CYOD " or "DYED
>> ".
>> | How can i write a macro that would eliminate all the empty spaces after
>> the
>> | first 4 letters??
>> |
>> | Thanks
>>
>>
>>



 
Reply With Quote
 
Saruman
Guest
Posts: n/a
 
      14th Feb 2008
Or just use the TRIM function.

=TRIM(A1) will remove excess spaces in cell A1

--
Saruman

---------------------------------------------------------------------------
All Outgoing Mail Scanned By Symantec Antivirus 10
---------------------------------------------------------------------------
"Don Doan" <(E-Mail Removed)> wrote in message
news:AE382C5D-99E0-4A77-B605-(E-Mail Removed)...
> Hi,
> Just a quick question.
> I have column D that always contained 4 letter characters. However, some

of
> the cells in that colum would have empty spaces following those

characters.
> For example, i can have something like this: "CYOD " or "DYED ".
> How can i write a macro that would eliminate all the empty spaces after

the
> first 4 letters??
>
> Thanks



 
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
Delete characters up to a space David# Microsoft Access Queries 1 15th Jul 2008 03:03 PM
Trim Characters Other Than An Empty Space At The End Of A Cell K8_Dog Microsoft Excel Worksheet Functions 5 19th Apr 2008 01:29 AM
How do I set the space bar to delete highlighted characters or wo lwaltman Microsoft Word Document Management 1 19th Dec 2007 07:10 PM
How do I delete empty header and footer space from my documents? =?Utf-8?B?U2ltcHNvbiBNY0NhcnJ5?= Microsoft Word Document Management 6 24th Oct 2006 04:16 AM
delete space between characters or numbers jskang Microsoft Excel New Users 4 9th Mar 2004 12:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:29 PM.