![]() |
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 |
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 |
Value between two spaces in a String
Thanks Nick!
This is exactly what I was looking for. |
Value between two spaces in a String
Thanks Nick!
This is exactly what I was looking for. |
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 |
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 |
All times are GMT +1. The time now is 09:44 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com