Sub GetInfo()
Dim RngColA As Range
Dim i As Range
Dim Info As String
Set RngColA = Range("A1", Range("A" & Rows.Count).End(xlUp))
Info = ""
For Each i In RngColA
If i.Value = Range("C1").Value Then
If Info = "" Then
Info = i.Offset(, 1).Value
Else
Info = Info & "," & i.Offset(, 1).Value
End If
End If
Next i
Range("D1")=Info 'I changed this line only.
Info = ""
End Sub
"Otto Moehrbach" wrote in message
...
This macro should help. I assumed your name data is in Column A starting
in A1 and the other information is in Column B, and the name you're
searching for is in C1. HTH Otto
Sub GetInfo()
Dim RngColA As Range
Dim i As Range
Dim Info As String
Set RngColA = Range("A1", Range("A" & Rows.Count).End(xlUp))
Info = ""
For Each i In RngColA
If i.Value = Range("C1").Value Then
If Info = "" Then
Info = i.Offset(, 1).Value
Else
Info = Info & "," & i.Offset(, 1).Value
End If
End If
Next i
MsgBox Info
Info = ""
End Sub
"John21" wrote in
message ...
Hi,
I'm looking for a way to search information in a column and then return
the text found in another column that has related information. The
problem is that the names in the column appear more than one time and
the names appear randomly.
exmaple:
John lmj,45
Maria HI45,kil
Jose
John U15,U78
John M60,lem
Angel lktr
Jenny
Angel nono,468
Maria
John return: lmj,45,U15,U78,M60,lem
Angel return: lktr,nono,468
--
John21
------------------------------------------------------------------------
John21's Profile:
http://www.excelforum.com/member.php...o&userid=36983
View this thread:
http://www.excelforum.com/showthread...hreadid=569097