Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default comparing text

I’m trying to write a simple search that would check the contents of a
cell for a variable search word. These cells contain several sentences
so I need it to pluck the word out of the cells and provide me with the
value in the next column. I can figure out how to do almost everything
else except compare the value of the cells with the search variable.

so how would i say this for example

If (any part of) activecell.value = Variable then msgbox
activecell.value

thanks everybody, Im new to this and appreciate any help greatly!


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default comparing text

starget = "word"
If instr(1,ActiveCell.Value,sTarget,vbTextCompare) Then
msgbox Activecell.Offset(0,1).Value
End if

A faster approach might be to use the Find method (the VBA equipvalent of
Edit=Find).

look at the help example (in the VBE) for the Find METHOD.

Also, turn on the macro recorder and do Find manually to get sample code.
--
Regards,
Tom Ogilvy

"bely" wrote in message
...
I'm trying to write a simple search that would check the contents of a
cell for a variable search word. These cells contain several sentences
so I need it to pluck the word out of the cells and provide me with the
value in the next column. I can figure out how to do almost everything
else except compare the value of the cells with the search variable.

so how would i say this for example

If (any part of) activecell.value = Variable then msgbox
activecell.value

thanks everybody, Im new to this and appreciate any help greatly!


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default comparing text


-----Original Message-----
I'm trying to write a simple search that would check the

contents of a
cell for a variable search word. These cells contain

several sentences
so I need it to pluck the word out of the cells and

provide me with the
value in the next column. I can figure out how to do

almost everything
else except compare the value of the cells with the

search variable.

so how would i say this for example

If (any part of) activecell.value = Variable then msgbox
activecell.value

thanks everybody, Im new to this and appreciate any help

greatly!


---
Message posted from http://www.ExcelForum.com/

.



Seems like you want to use the like operator.

This will pattern match for charcters, numbers and more
importantly strings.

Look at the help for for more info.

Its simple to use.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default comparing text

Thanks guys, that worked!


---
Message posted from http://www.ExcelForum.com/

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
Comparing text and then adding numbers if the text matches rotor11 Excel Worksheet Functions 2 April 8th 09 08:38 PM
comparing text against a text table for yes no result Nigel Toates Excel Discussion (Misc queries) 3 November 30th 07 12:30 AM
Comparing Text beginner here Excel Worksheet Functions 7 July 18th 07 11:52 PM
Please help ... comparing text Sally M. Excel Worksheet Functions 2 June 10th 07 02:27 PM
comparing text cells Comander Excel Worksheet Functions 2 June 5th 06 10:00 PM


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