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

Hi, I have been putting together a program for the past
year in vb/excel and I am stuck on the last macro to put
this whole thing to bed. Here is the problem:
On one worksheet there is a range of cells that has
comments. cell(A1) (ei "3wd, rounding corner")
I need to look into each cell and determine whether a
portion of the cell contains certain words or abreviations
(ie "3wd","steadied","std","5wd") and then assigning a
variable a value.
I have tried making a function with TextCompare but keep
running into errors. Recording a "Find" macro puts me
into another whirlwind. It seems to easy to be this hard.
Either I am getting old or losing my mind. Thank you in
advance for your help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Searching text in cells

This is untested. Watch for linewrap. Not sure whether you are
searching comments or cells. Also not sure how many cells you wish to
search. I have no idea what you mean by 'then assigning a
variable a value'. But this should push you in one direction.

Sub FindPhrase()

Dim intI as Integer
Dim rngC as Range, rngCom as Range
Dim rngFound as Range
Dim varArray As Variant

varArray = Array("3wd","steadied","std","5wd")
Set rngCom = Range(YourRangeToSearch)

For intI = LBound(varArray) To UBound(varArray)

For Each rngC In rngCom
Set rngFound = rngC.Find(What:=varArray(intI),
Lookat:=xlPart,Lookin:=xlFormulas)
' Set rngFound = rngC.Find(What:=varArray(intI),
'Lookat:=xlPart,LookIn:=xlComments)
If Not rngFound Is Nothing Then
rngC.Font.ColorIndex=3
End If
Next rngC

Next intI

End Sub

HTH
Paul
--------------------------------------------------------------------------------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
--------------------------------------------------------------------------------------------------------------
Hi, I have been putting together a program for the past
year in vb/excel and I am stuck on the last macro to put
this whole thing to bed. Here is the problem:
On one worksheet there is a range of cells that has
comments. cell(A1) (ei "3wd, rounding corner")
I need to look into each cell and determine whether a
portion of the cell contains certain words or abreviations
(ie "3wd","steadied","std","5wd") and then assigning a
variable a value.
I have tried making a function with TextCompare but keep
running into errors. Recording a "Find" macro puts me
into another whirlwind. It seems to easy to be this hard.
Either I am getting old or losing my mind. Thank you in
advance for your help.


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 for text EBnLP01 Excel Worksheet Functions 2 July 14th 09 08:32 PM
Searching a text string in a range of cells. heenanmc Excel Worksheet Functions 2 August 15th 06 05:53 PM
help searching text Nikko Excel Discussion (Misc queries) 2 April 28th 05 03:32 PM
Searching for text in cells Matt Excel Discussion (Misc queries) 1 January 31st 05 03:16 AM
Searching text Dave Peterson[_3_] Excel Programming 0 August 21st 03 03:41 AM


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