Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 50
Default Find specific info within a text string using VBA

I have an order number embeeded in the title of an email. For example, the
order number below is 09-11111
" 09-11111 sent to customer Jones"
The order number is not necessarily in the same spot for each email.

I am comparing two worksheets to see what does not match between the orders
and emails sent.

Using the following works for the above scenario--it finds the order #09-11111
Set C = .Find(OrderNum, LookIn:=xlValues)

Unfortunately, there can be revisions to the order, e.g., 09-11111_2 or
09-11111_3, etc.

The "find method" searches within a string, and when I need to locate JUST
09-11111, it finds it when it comes across the email containing 09-11111_2.
I need it to find the exact string within the email text, e.g, " 09-11111
sent to customer Jones" and NOT "This is in response to your order of
09-11111_2".

Can you think of an alternative way to search?

Any help would be greatly appreciated.




  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Find specific info within a text string using VBA

Hi

The below code using INSTR looks for an exact match and returns 0 if no
match found. If there is a match it returns the position.

Dim strETitle as String
Dim strSearch as String

strETitle = "your email title"
strSearch = "09-11111"

=Instr(1," " & strETitle & " "," " & strSearch & " ",vbTextCompare )


If this post helps click Yes
---------------
Jacob Skaria


"laavista" wrote:

I have an order number embeeded in the title of an email. For example, the
order number below is 09-11111
" 09-11111 sent to customer Jones"
The order number is not necessarily in the same spot for each email.

I am comparing two worksheets to see what does not match between the orders
and emails sent.

Using the following works for the above scenario--it finds the order #09-11111
Set C = .Find(OrderNum, LookIn:=xlValues)

Unfortunately, there can be revisions to the order, e.g., 09-11111_2 or
09-11111_3, etc.

The "find method" searches within a string, and when I need to locate JUST
09-11111, it finds it when it comes across the email containing 09-11111_2.
I need it to find the exact string within the email text, e.g, " 09-11111
sent to customer Jones" and NOT "This is in response to your order of
09-11111_2".

Can you think of an alternative way to search?

Any help would be greatly appreciated.




  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Find specific info within a text string using VBA

Attach space to the search string before find

OrderNum = " " & Cstr(OrderNum) & " "

--
If this post helps click Yes
---------------
Jacob Skaria


"laavista" wrote:

I have an order number embeeded in the title of an email. For example, the
order number below is 09-11111
" 09-11111 sent to customer Jones"
The order number is not necessarily in the same spot for each email.

I am comparing two worksheets to see what does not match between the orders
and emails sent.

Using the following works for the above scenario--it finds the order #09-11111
Set C = .Find(OrderNum, LookIn:=xlValues)

Unfortunately, there can be revisions to the order, e.g., 09-11111_2 or
09-11111_3, etc.

The "find method" searches within a string, and when I need to locate JUST
09-11111, it finds it when it comes across the email containing 09-11111_2.
I need it to find the exact string within the email text, e.g, " 09-11111
sent to customer Jones" and NOT "This is in response to your order of
09-11111_2".

Can you think of an alternative way to search?

Any help would be greatly appreciated.




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 we find specific word from string in excel and compaire it. Vishnu Excel Worksheet Functions 2 April 18th 09 07:51 AM
How to Find Specific Text in a Text String Confused_in_Houston[_2_] Excel Discussion (Misc queries) 2 January 26th 09 08:17 PM
Find a specific formatted string in a cell KCK Excel Worksheet Functions 1 April 16th 08 09:16 PM
Find specific value in a string Lost in Microbiology Excel Discussion (Misc queries) 8 May 16th 07 09:58 AM
can you find specific text in a string ignoring any other text chriscp Excel Discussion (Misc queries) 1 September 18th 05 09:54 PM


All times are GMT +1. The time now is 06:57 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"