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

Hi. I have a loop where I would like to search for the
text, "Item:" within the cells. For instance, I would
want it to find "Item: 7201".

What command line should I use to find cells
containing "Item:".

Thanks,
Mike.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Finding text within a cell

Hi Mike
have a look at the InStr method in VBA

--
Regards
Frank Kabel
Frankfurt, Germany


Mike wrote:
Hi. I have a loop where I would like to search for the
text, "Item:" within the cells. For instance, I would
want it to find "Item: 7201".

What command line should I use to find cells
containing "Item:".

Thanks,
Mike.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Finding text within a cell

Try something like this
assumin data is in column 1 ("A")
strSearch = "Item:"
for I = Toprow to bottomrow
If left(cells(I,1),5) =strSearch then
Msgbox "Found on Row " & I '
Exit For
End if
Next

Trev
-----Original Message-----
Hi. I have a loop where I would like to search for the
text, "Item:" within the cells. For instance, I would
want it to find "Item: 7201".

What command line should I use to find cells
containing "Item:".

Thanks,
Mike.
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Finding text within a cell

Hi Mike

You must use
LookAt:=xlPart in your code

Here is a example that look in column A for Item and color the cell

Sub Color_cells_in_Column()
Dim FirstAddress As String
Dim myArr As Variant
Dim rng As Range
Dim I As Long

Application.ScreenUpdating = False
myArr = Array("Item")
'You can also use more values in the Array
'myArr = Array("ron", "dave")

With Sheets("Sheet1").Range("A:A")

.Interior.ColorIndex = xlColorIndexNone
'change the fill color to "no fill" in all cells

For I = LBound(myArr) To UBound(myArr)
Set rng = .Find(What:=myArr(I), _
After:=Range("A" & Rows.Count), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
'if you use LookIn:=xlValues it will also work with a
'a formula cell that evaluates to "ron"

If Not rng Is Nothing Then
FirstAddress = rng.Address
Do
rng.Interior.ColorIndex = 3
'make the cell red
Set rng = .FindNext(rng)
Loop While Not rng Is Nothing And rng.Address < FirstAddress
End If
Next I
End With
Application.ScreenUpdating = True
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Mike" wrote in message ...
Hi. I have a loop where I would like to search for the
text, "Item:" within the cells. For instance, I would
want it to find "Item: 7201".

What command line should I use to find cells
containing "Item:".

Thanks,
Mike.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Finding text within a cell

Hi Mike,

On Error Resume Next
oCell = Cells.Find("Item")
If Not oCell Is Nothing Then
msgbox "Item found at " & oCell.Address
End If
On Error Goto 0

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mike" wrote in message
...
Hi. I have a loop where I would like to search for the
text, "Item:" within the cells. For instance, I would
want it to find "Item: 7201".

What command line should I use to find cells
containing "Item:".

Thanks,
Mike.





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
Finding Text in a cell Klee Excel Worksheet Functions 3 February 20th 08 05:34 PM
Finding text in a cell and returning a value based on that text [email protected] Excel Discussion (Misc queries) 5 January 10th 07 06:01 PM
Finding text in a cell Art Excel Worksheet Functions 8 December 3rd 06 06:47 PM
Finding a text string w/in a Cell ricxl Excel Discussion (Misc queries) 12 March 20th 06 03:47 AM
Finding Partial Text in a Cell bob Excel Worksheet Functions 6 December 18th 04 05:03 AM


All times are GMT +1. The time now is 10:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"