PDA

View Full Version : How do you search a cell for key words?



PliskinAJ
06-01-2007, 01:56 PM
How do you search a cell for a key word. Automatically without any message windows and such.

For example:

Part..... description
1 ....... yellow 5 foot tall
2 ....... green 5 foot tall
3 ....... yellow 2 foot tall
4 ....... blue 7 foot tall

I was wondering if it is at all possible to search the description cells and find both yellows and copy each row accordingly. It seems if i search the cells for yellow I wont get any of the cells because the values are "yellow 5 foot tall" and "yellow 2 foot tall" I just started using VBA and I seem to be spending all my time looking up commands. I am familiar with coding tho. Any help would be great.

What i want to do in the long run is have it set up so I have yellow, green and blue worksheets. So when I load my list from another program it will automatically sort out the list into the proper worksheets. I think I can handle the moving the rows around I just can't find anything to help me with the search.

Thanks.: pray2:

mdmackillop
06-01-2007, 02:13 PM
Here's a recorded macro. By removing the tick from Match entire cell contents, you get a partial search as in xlPart. Have a look at this thread (http://vbaexpress.com/forum/showpost.php?p=101326&postcount=8)
Sub Macro3()
Cells.Find(What:="yellow", After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
End Sub

PliskinAJ
06-01-2007, 02:55 PM
Wow thanks for the reply. Ill try it.