Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Value between two spaces in a String

Hi,

I have string like that :

NESN 380.7 STR 01/28/2008

and I want to be able to grab the value between the first two spaces;
380.7. I know how to find the first space but I don't know how to find
the second one.

Does anyone know?

Thanks,

Kathy

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default Value between two spaces in a String

Kathy,
Fuction GetPart(InputStr as string, Position as long, Optional Delim as
string=" ") as string
GetPart=Split(InputStr,Delim)(position)
'Add error handling in case invalid values
End Function

So call it with :
Dim Val as variant
Val=GetPart("NESN 380.7 STR 01/28/2008",2)

NickHK


egroups.com...
Hi,

I have string like that :

NESN 380.7 STR 01/28/2008

and I want to be able to grab the value between the first two spaces;
380.7. I know how to find the first space but I don't know how to find
the second one.

Does anyone know?

Thanks,

Kathy



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Value between two spaces in a String

Thanks Nick!
This is exactly what I was looking for.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Value between two spaces in a String

Thanks Nick!
This is exactly what I was looking for.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Value between two spaces in a String

Nick,

Nice, except Split returns a 0 based array, so you should use

GetPart=Split(InputStr,Delim)(position - 1)

HTH,
Bernie
MS Excel MVP


"NickHK" wrote in message ...
Kathy,
Fuction GetPart(InputStr as string, Position as long, Optional Delim as string=" ") as string
GetPart=Split(InputStr,Delim)(position)
'Add error handling in case invalid values
End Function

So call it with :
Dim Val as variant
Val=GetPart("NESN 380.7 STR 01/28/2008",2)

NickHK

egroups.com...
Hi,

I have string like that :

NESN 380.7 STR 01/28/2008

and I want to be able to grab the value between the first two spaces;
380.7. I know how to find the first space but I don't know how to find
the second one.

Does anyone know?

Thanks,

Kathy







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default Value between two spaces in a String

Bernie,
Yeah, it's getting late here. And not testing what you write, however
(apparently) simple.
Thanks

NickHK

"Bernie Deitrick" <deitbe @ consumer dot org .gbl...
Nick,

Nice, except Split returns a 0 based array, so you should use

GetPart=Split(InputStr,Delim)(position - 1)

HTH,
Bernie
MS Excel MVP


"NickHK" wrote in message
...
Kathy,
Fuction GetPart(InputStr as string, Position as long, Optional Delim as
string=" ") as string
GetPart=Split(InputStr,Delim)(position)
'Add error handling in case invalid values
End Function

So call it with :
Dim Val as variant
Val=GetPart("NESN 380.7 STR 01/28/2008",2)

NickHK


egroups.com...
Hi,

I have string like that :

NESN 380.7 STR 01/28/2008

and I want to be able to grab the value between the first two spaces;
380.7. I know how to find the first space but I don't know how to find
the second one.

Does anyone know?

Thanks,

Kathy







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
Find String in another string - only between spaces Nir Excel Worksheet Functions 9 November 2nd 06 11:31 AM
Removing Spaces from string katmando Excel Worksheet Functions 4 May 16th 06 02:16 PM
counting spaces in a string xnman Excel Programming 7 May 9th 04 03:06 PM
counting spaces in a string xnman Excel Programming 4 December 16th 03 01:36 AM
Count Spaces In A String Josh in Tampa Excel Programming 2 October 23rd 03 05:59 PM


All times are GMT +1. The time now is 06:39 PM.

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"