Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default delete empty space after certain characters

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default delete empty space after certain characters

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
EditCopy
Select D1
EditPaste 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" wrote in message ...
| 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default delete empty space after certain characters

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
EditCopy
Select D1
EditPaste 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" wrote in message ...
| 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default delete empty space after certain characters

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" wrote in message
...
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
EditCopy
Select D1
EditPaste 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" wrote in message
...
| 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





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default delete empty space after certain characters

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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trim Characters Other Than An Empty Space At The End Of A Cell K8_Dog Excel Worksheet Functions 5 April 19th 08 01:29 AM
Put A Space Between 2 right characters carl Excel Worksheet Functions 3 April 8th 08 05:08 PM
how can I insert a space every three characters? Sam Excel Programming 4 February 14th 07 07:25 PM
cHARACTERS BEFORE THE SPACE T De Villiers Excel Worksheet Functions 3 January 19th 06 01:22 AM
Characters before the space T De Villiers[_8_] Excel Programming 3 January 18th 06 10:22 PM


All times are GMT +1. The time now is 09:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"