PDA

View Full Version : Solved: Find text in columns



u25103
02-24-2008, 12:52 PM
Hi
Here is my problem

I want to search and find text i column A and with the text that is in the first cell in column B (B1) and then go to B2 and so on....... :think:

My code just search the text within B1 but how do a make the code so it go to the next cell in B column



This is my "code":(

Dim R As Range, FindAddress As String

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

Set R = .Find(Range("C1"))

If Not R Is Nothing Then

FindAddress = R.Address
Do

R.Select

Set R = .FindNext(R)


Loop While Not R Is Nothing And R.Address <> FindAddress
End If
End With

'delete memory
Set R = Nothing


Please :help ..... Thanks:bow:

Bob Phillips
02-24-2008, 04:31 PM
Dim LastRow As Long
Dim i As Long
Dim R As Range, FindAddress As String

With Sheets(1)

LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row

For i = 1 To LastRow

Set R = Nothing
Set R = .Find(.Cells(i, "B").Value)
If Not R Is Nothing Then

R.Select
End If
Next i
End With

'delete memory
Set R = Nothing

u25103
02-24-2008, 10:48 PM
Thanks.

But the code dosen't find any text in cell b1. I did a "interior.colorindex" and it only highlighted the empty cells:think: in range i want it to search in. "With Sheets(1).Range("A:A")


Dim LastRow As Long
Dim i As Long
Dim R As Range, FindAddress As String

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

LastRow = .cells(.Rows.Count, "B").End(xlUp).Row

For i = 1 To LastRow

Set R = .Find(.cells(i, "B").Value)

If Not R Is Nothing Then
Do

R.Select
Selection.Interior.ColorIndex = 40
Set R = .FindNext(R)
Loop While Not R Is Nothing And R.Address <> FindAddress

End If
Next i
End With

'delete memory
Set R = Nothing


?????????

david000
02-25-2008, 01:59 AM
I think you need to; find - then perform an act - then find again. right?

I attacheted an example with a listbox to populate column B then find the item selected in column A.


(Find_Function, via Aaron T. Blood)