Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Find Data in a String

Within some code in a macro I have a variable
called "Temp" that can hold data like:

BFYS: 94FUND:FUND:0160X4
or
BFYS: 01 02FUND:FUND:0160X4

I want to parse out (capture) two variables:
1. The characters between the first colon and the
first "FUND" word.
2. The characters after the third colon.

In the frist example variable one would equal "94" and two
would be "0160X4."
In the second example they would be "01 02" and "0160X4."

I tried using the "Find" operator, but couldn't get it to
work.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Find Data in a String


temp = "BFYS: 94FUND:FUND:0160X4"
iloc1 = Instr(1,Temp,":",vbTextCompare)
iloc2 = Instr(1,Temp,"fund",vbTextCompare)
? Mid(temp,iloc1+1,iloc2-iloc1-1)
94
iloc3 =
Instr(instr(iloc1+1,temp,":",vbTextCompare)+1,Temp ,":",vbTextcompare)
? right(temp,len(temp)-iloc3)
0160X4

---------------

temp = "BFYS: 01 02FUND:FUND:0160X4"
iloc1 = Instr(1,Temp,":",vbTextCompare)
iloc2 = Instr(1,Temp,"fund",vbTextCompare)
? Mid(temp,iloc1+1,iloc2-iloc1-1)
01 02
iloc3 =
Instr(instr(iloc1+1,temp,":",vbTextCompare)+1,Temp ,":",vbTextcompare)
? right(temp,len(temp)-iloc3)
0160X4

--

Regards,
Tom Ogilvy


"Bill" wrote in message
...
Within some code in a macro I have a variable
called "Temp" that can hold data like:

BFYS: 94FUND:FUND:0160X4
or
BFYS: 01 02FUND:FUND:0160X4

I want to parse out (capture) two variables:
1. The characters between the first colon and the
first "FUND" word.
2. The characters after the third colon.

In the frist example variable one would equal "94" and two
would be "0160X4."
In the second example they would be "01 02" and "0160X4."

I tried using the "Find" operator, but couldn't get it to
work.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Find Data in a String

Worked great. Thanks for assistance!
I'll add "Instr" function to my "knowledge base."
-----Original Message-----

temp = "BFYS: 94FUND:FUND:0160X4"
iloc1 = Instr(1,Temp,":",vbTextCompare)
iloc2 = Instr(1,Temp,"fund",vbTextCompare)
? Mid(temp,iloc1+1,iloc2-iloc1-1)
94
iloc3 =
Instr(instr(iloc1+1,temp,":",vbTextCompare)

+1,Temp,":",vbTextcompare)
? right(temp,len(temp)-iloc3)
0160X4

---------------

temp = "BFYS: 01 02FUND:FUND:0160X4"
iloc1 = Instr(1,Temp,":",vbTextCompare)
iloc2 = Instr(1,Temp,"fund",vbTextCompare)
? Mid(temp,iloc1+1,iloc2-iloc1-1)
01 02
iloc3 =
Instr(instr(iloc1+1,temp,":",vbTextCompare)

+1,Temp,":",vbTextcompare)
? right(temp,len(temp)-iloc3)
0160X4

--

Regards,
Tom Ogilvy


"Bill" wrote in

message
...
Within some code in a macro I have a variable
called "Temp" that can hold data like:

BFYS: 94FUND:FUND:0160X4
or
BFYS: 01 02FUND:FUND:0160X4

I want to parse out (capture) two variables:
1. The characters between the first colon and the
first "FUND" word.
2. The characters after the third colon.

In the frist example variable one would equal "94" and

two
would be "0160X4."
In the second example they would be "01 02"

and "0160X4."

I tried using the "Find" operator, but couldn't get it

to
work.



.

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
Find Many String options in ONE String Nir Excel Worksheet Functions 6 October 26th 06 07:13 AM
Macro to find text string in a column and paste data in another nicolascap Excel Discussion (Misc queries) 8 March 14th 06 03:13 PM
find a string inside another string MarkS Excel Programming 1 January 13th 04 02:55 AM
Wish to parse through a text string to find data Neil Bhandar[_2_] Excel Programming 2 October 24th 03 07:04 PM


All times are GMT +1. The time now is 05:14 AM.

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"