Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default # of Spaces macro

is there a way to write a macro that looks at a field of
data and counts the number of spaces in it. i.e.:

Field 1
|Dave Jones 2100 Wind Street Anytown AK 11021|

So I would want the macro to recognize there being "7"
spaces in this record and based on that place it into a
specific worksheet. Any help is greatly appreciated.
thank you.

Peter.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default # of Spaces macro

Hi
do you need a VBA solution or would a worksheet formula work as well?.
For the latter one try
=LEN(A1)-LEN(SUBSTITUTE(A1," ",""))

--
Regards
Frank Kabel
Frankfurt, Germany

"Peter" schrieb im Newsbeitrag
...
is there a way to write a macro that looks at a field of
data and counts the number of spaces in it. i.e.:

Field 1
|Dave Jones 2100 Wind Street Anytown AK 11021|

So I would want the macro to recognize there being "7"
spaces in this record and based on that place it into a
specific worksheet. Any help is greatly appreciated.
thank you.

Peter.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default # of Spaces macro

len(sStr) - len(replace(sStr," ",""))

use application.Substitute if using xl97 or earlier.

--
Regards,
Tom Ogilvy

"Peter" wrote in message
...
is there a way to write a macro that looks at a field of
data and counts the number of spaces in it. i.e.:

Field 1
|Dave Jones 2100 Wind Street Anytown AK 11021|

So I would want the macro to recognize there being "7"
spaces in this record and based on that place it into a
specific worksheet. Any help is greatly appreciated.
thank you.

Peter.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default # of Spaces macro

thanks to both of you for the help. i appreciate your
sharing of knowledge
-----Original Message-----
is there a way to write a macro that looks at a field of
data and counts the number of spaces in it. i.e.:

Field 1
|Dave Jones 2100 Wind Street Anytown AK 11021|

So I would want the macro to recognize there being "7"
spaces in this record and based on that place it into a
specific worksheet. Any help is greatly appreciated.
thank you.

Peter.
.

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
how do I remove leading spaces and leave the remianing spaces w Debi Excel Worksheet Functions 6 February 28th 07 03:29 PM
spaces not recognized as spaces windsurferLA Excel Worksheet Functions 9 July 27th 06 11:49 AM
Macro that double spaces rows for an entire worksheet? glaves123 Excel Discussion (Misc queries) 1 November 6th 05 03:42 AM
Need simple little macro - edit add 3 spaces John Grossman Excel Worksheet Functions 4 August 2nd 05 06:12 PM
macro to eliminate spaces between words CSAM Excel Discussion (Misc queries) 3 December 17th 04 11:39 AM


All times are GMT +1. The time now is 04:37 PM.

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

About Us

"It's about Microsoft Excel"