Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Finding Text in a cell | Excel Worksheet Functions | |||
Finding text in a cell and returning a value based on that text | Excel Discussion (Misc queries) | |||
Finding text in a cell | Excel Worksheet Functions | |||
Finding a text string w/in a Cell | Excel Discussion (Misc queries) | |||
Finding Partial Text in a Cell | Excel Worksheet Functions |