Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Searching for patterns in text split into adjacent cells

Hi,

If I have data in cells such as YDR DYH VNB etc, in separate cells, and I
want to search for a pattern that can span multiple cells how do I do this?
Suppose I want to search the cells for the pattern DRDY (which includes
characters in cells 1 and 2) and color it when its found in the above example?

Matt
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Searching for patterns in text split into adjacent cells

How about something like
=FIND("DRDY",A6&B6&C6), which returns the value 2 in your example.
If "DRDY" is not found then the formula will return Value#.
hth
ScottO

"chemdude77" wrote in message
...
| Hi,
|
| If I have data in cells such as YDR DYH VNB etc, in separate cells,
and I
| want to search for a pattern that can span multiple cells how do I
do this?
| Suppose I want to search the cells for the pattern DRDY (which
includes
| characters in cells 1 and 2) and color it when its found in the
above example?
|
| Matt


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Searching for patterns in text split into adjacent cells

Hi Scott,

Thanks for the reply this is exactly what I'm looking for!

Matt

"ScottO" wrote:

How about something like
=FIND("DRDY",A6&B6&C6), which returns the value 2 in your example.
If "DRDY" is not found then the formula will return Value#.
hth
ScottO

"chemdude77" wrote in message
...
| Hi,
|
| If I have data in cells such as YDR DYH VNB etc, in separate cells,
and I
| want to search for a pattern that can span multiple cells how do I
do this?
| Suppose I want to search the cells for the pattern DRDY (which
includes
| characters in cells 1 and 2) and color it when its found in the
above example?
|
| Matt



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Searching for patterns in text split into adjacent cells

Actually, I may have gotten excited too early as my code is failing now. The
problem is when the FIND command doesn't find the string the code crashes
with error 1004: Unable to get the Find property of the WorksheetFunction
class. Any idea how to fix this? Here is relevant code so far:

position = Application.WorksheetFunction.Find("AYRT", rng.Cells(1, k) &
rng.Cells(1, k + 1))

And then I have If-Then statements to evaluate the strating position of the
string and color it accordingly. Final statement is an Else to start back at
the top if the string doesnt exit, but this is the part that doesn't work.
Any way to have it move on to the next k value if the string isn't found?

Thanks

Matt



"chemdude77" wrote:

Hi Scott,

Thanks for the reply this is exactly what I'm looking for!

Matt

"ScottO" wrote:

How about something like
=FIND("DRDY",A6&B6&C6), which returns the value 2 in your example.
If "DRDY" is not found then the formula will return Value#.
hth
ScottO

"chemdude77" wrote in message
...
| Hi,
|
| If I have data in cells such as YDR DYH VNB etc, in separate cells,
and I
| want to search for a pattern that can span multiple cells how do I
do this?
| Suppose I want to search the cells for the pattern DRDY (which
includes
| characters in cells 1 and 2) and color it when its found in the
above example?
|
| Matt



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Searching for patterns in text split into adjacent cells

Nevermind, I fixed the problem by switching to Mid statements:

For k = 1 To L - 1

position1 = Mid((rng.Cells(1, k) & rng.Cells(1, k + 1)), 1, 4)
position2 = Mid((rng.Cells(1, k) & rng.Cells(1, k + 1)), 2, 4)
position3 = Mid((rng.Cells(1, k) & rng.Cells(1, k + 1)), 3, 4)

And then If-thens to evaluate.

Everything's working now.

Matt

"chemdude77" wrote:

Actually, I may have gotten excited too early as my code is failing now. The
problem is when the FIND command doesn't find the string the code crashes
with error 1004: Unable to get the Find property of the WorksheetFunction
class. Any idea how to fix this? Here is relevant code so far:

position = Application.WorksheetFunction.Find("AYRT", rng.Cells(1, k) &
rng.Cells(1, k + 1))

And then I have If-Then statements to evaluate the strating position of the
string and color it accordingly. Final statement is an Else to start back at
the top if the string doesnt exit, but this is the part that doesn't work.
Any way to have it move on to the next k value if the string isn't found?

Thanks

Matt



"chemdude77" wrote:

Hi Scott,

Thanks for the reply this is exactly what I'm looking for!

Matt

"ScottO" wrote:

How about something like
=FIND("DRDY",A6&B6&C6), which returns the value 2 in your example.
If "DRDY" is not found then the formula will return Value#.
hth
ScottO

"chemdude77" wrote in message
...
| Hi,
|
| If I have data in cells such as YDR DYH VNB etc, in separate cells,
and I
| want to search for a pattern that can span multiple cells how do I
do this?
| Suppose I want to search the cells for the pattern DRDY (which
includes
| characters in cells 1 and 2) and color it when its found in the
above example?
|
| Matt



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
Searching Multiples Words in cells and returing it in adjacent cell azhar.abidi New Users to Excel 0 January 16th 12 06:37 PM
How do I combine text from adjacent cells? Qegmag Excel Worksheet Functions 2 January 8th 08 01:30 AM
text cells end page how split to next. Text lost! Elaine Excel Discussion (Misc queries) 1 August 28th 05 05:48 PM
Searching for text in cells Matt Excel Discussion (Misc queries) 1 January 31st 05 03:16 AM
Searching text in cells troistr Excel Programming 1 October 14th 03 07:51 AM


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