Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 51
Default Return multiple values in one cell doing a single value lookup

Here's the scenario:

A B C D
1 Blue Blue John
2 Yellow Black Mary
3 Black Yellow Carol
4 Yellow Terri
5 Black Joe
6 Blue Tracy


What I need is a formula in Column A that will return all the names in
Column D where Column C matches Column B. So the results would look like
this:

A B C D
1 John, Tracy Blue Blue John
2 Carol, Terri Yellow Black Mary
3 Mary, Joe Black Yellow Carol
4 Yellow Terri
5 Black Joe
6 Blue Tracy

I'm using Excel 2003. This is a small sample, the spreadsheet I'm working
with is much larger. I can't attach the file because it contains
confidential information.

Thanks.


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,646
Default Return multiple values in one cell doing a single value lookup

I think that it can be done only with a UDF:

Function findcolor(brng As String) As String
Dim c As Range
With Range("C:C")
Set c = .Find(brng)
If Not c Is Nothing Then
firstAddress = c.Address
Do
result = result & Range("D" & c.Row) & ","
Set c = .Find(brng, c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
If Len(result) = 0 Then
findcolor = result
Else
findcolor = Left(result, Len(result) - 1)
End If
End Function

Usage (in A2, it's advisable to insert a header row):
=findcolor(B2)

Regards,
Stefi

€žMelody€ť ezt Ă*rta:

Here's the scenario:

A B C D
1 Blue Blue John
2 Yellow Black Mary
3 Black Yellow Carol
4 Yellow Terri
5 Black Joe
6 Blue Tracy


What I need is a formula in Column A that will return all the names in
Column D where Column C matches Column B. So the results would look like
this:

A B C D
1 John, Tracy Blue Blue John
2 Carol, Terri Yellow Black Mary
3 Mary, Joe Black Yellow Carol
4 Yellow Terri
5 Black Joe
6 Blue Tracy

I'm using Excel 2003. This is a small sample, the spreadsheet I'm working
with is much larger. I can't attach the file because it contains
confidential information.

Thanks.


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 51
Default Return multiple values in one cell doing a single value lookup

How do you guys learn this stuff? Wow. How do I define the range if C:C is
actually on Sheet 2 Column A and Column D is actually on Sheet 2 Column B?

Thanks,

"Stefi" wrote:

I think that it can be done only with a UDF:

Function findcolor(brng As String) As String
Dim c As Range
With Range("C:C")
Set c = .Find(brng)
If Not c Is Nothing Then
firstAddress = c.Address
Do
result = result & Range("D" & c.Row) & ","
Set c = .Find(brng, c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
If Len(result) = 0 Then
findcolor = result
Else
findcolor = Left(result, Len(result) - 1)
End If
End Function

Usage (in A2, it's advisable to insert a header row):
=findcolor(B2)

Regards,
Stefi

€žMelody€ť ezt Ă*rta:

Here's the scenario:

A B C D
1 Blue Blue John
2 Yellow Black Mary
3 Black Yellow Carol
4 Yellow Terri
5 Black Joe
6 Blue Tracy


What I need is a formula in Column A that will return all the names in
Column D where Column C matches Column B. So the results would look like
this:

A B C D
1 John, Tracy Blue Blue John
2 Carol, Terri Yellow Black Mary
3 Mary, Joe Black Yellow Carol
4 Yellow Terri
5 Black Joe
6 Blue Tracy

I'm using Excel 2003. This is a small sample, the spreadsheet I'm working
with is much larger. I can't attach the file because it contains
confidential information.

Thanks.


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 51
Default Return multiple values in one cell doing a single value lookup

Still waiting on how to adjust where the data is being referenced from.
Also, what needs to be added to not duplicate names in the list. In other
words if John's name in Column D has more than one Black record in Column C
just return John's name once in Column A.

Thanks.

"Melody" wrote:

How do you guys learn this stuff? Wow. How do I define the range if C:C is
actually on Sheet 2 Column A and Column D is actually on Sheet 2 Column B?

Thanks,

"Stefi" wrote:

I think that it can be done only with a UDF:

Function findcolor(brng As String) As String
Dim c As Range
With Range("C:C")
Set c = .Find(brng)
If Not c Is Nothing Then
firstAddress = c.Address
Do
result = result & Range("D" & c.Row) & ","
Set c = .Find(brng, c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
If Len(result) = 0 Then
findcolor = result
Else
findcolor = Left(result, Len(result) - 1)
End If
End Function

Usage (in A2, it's advisable to insert a header row):
=findcolor(B2)

Regards,
Stefi

€žMelody€ť ezt Ă*rta:

Here's the scenario:

A B C D
1 Blue Blue John
2 Yellow Black Mary
3 Black Yellow Carol
4 Yellow Terri
5 Black Joe
6 Blue Tracy


What I need is a formula in Column A that will return all the names in
Column D where Column C matches Column B. So the results would look like
this:

A B C D
1 John, Tracy Blue Blue John
2 Carol, Terri Yellow Black Mary
3 Mary, Joe Black Yellow Carol
4 Yellow Terri
5 Black Joe
6 Blue Tracy

I'm using Excel 2003. This is a small sample, the spreadsheet I'm working
with is much larger. I can't attach the file because it contains
confidential information.

Thanks.


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,646
Default Return multiple values in one cell doing a single value lookup

Sorry for the late answer but I've just now realized that my e-mail
notification doesn't work.
1. The best "getting started" is recording macros, reading VBA Help and Edit
recorded macros.
2. Worksheets("Sheet2").Range("C:C")
Worksheets("Sheet2").Range("D" & c.Row)
etc.
3. for eliminating duplicates:

Function findcolor(brng As String) As String
Dim c As Range
With Range("C:C")
Set c = .Find(brng)
If Not c Is Nothing Then
firstAddress = c.Address
Do
If InStr(1, result, Range("D" & c.Row)) = 0 Then _
result = result & Range("D" & c.Row) & ","
Set c = .Find(brng, c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
If Len(result) = 0 Then
findcolor = result
Else
findcolor = Left(result, Len(result) - 1)
End If
End Function

--
Regards!
Stefi



€žMelody€ť ezt Ă*rta:

Still waiting on how to adjust where the data is being referenced from.
Also, what needs to be added to not duplicate names in the list. In other
words if John's name in Column D has more than one Black record in Column C
just return John's name once in Column A.

Thanks.

"Melody" wrote:

How do you guys learn this stuff? Wow. How do I define the range if C:C is
actually on Sheet 2 Column A and Column D is actually on Sheet 2 Column B?

Thanks,

"Stefi" wrote:

I think that it can be done only with a UDF:

Function findcolor(brng As String) As String
Dim c As Range
With Range("C:C")
Set c = .Find(brng)
If Not c Is Nothing Then
firstAddress = c.Address
Do
result = result & Range("D" & c.Row) & ","
Set c = .Find(brng, c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
If Len(result) = 0 Then
findcolor = result
Else
findcolor = Left(result, Len(result) - 1)
End If
End Function

Usage (in A2, it's advisable to insert a header row):
=findcolor(B2)

Regards,
Stefi

€žMelody€ť ezt Ă*rta:

Here's the scenario:

A B C D
1 Blue Blue John
2 Yellow Black Mary
3 Black Yellow Carol
4 Yellow Terri
5 Black Joe
6 Blue Tracy


What I need is a formula in Column A that will return all the names in
Column D where Column C matches Column B. So the results would look like
this:

A B C D
1 John, Tracy Blue Blue John
2 Carol, Terri Yellow Black Mary
3 Mary, Joe Black Yellow Carol
4 Yellow Terri
5 Black Joe
6 Blue Tracy

I'm using Excel 2003. This is a small sample, the spreadsheet I'm working
with is much larger. I can't attach the file because it contains
confidential information.

Thanks.


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
Needing to return multiple values from single column [email protected] Excel Worksheet Functions 1 June 19th 07 07:27 AM
Using a lookup to return multiple values in one cell?? [email protected] Excel Discussion (Misc queries) 4 July 7th 06 01:50 PM
Using a lookup to return multiple values in one cell?? zim_zimmer Excel Worksheet Functions 1 July 7th 06 01:00 PM
Using a lookup to return multiple values in one cell?? zim_zimmer New Users to Excel 1 July 7th 06 10:28 AM
Search multiple values to return single values JANA Excel Worksheet Functions 8 October 27th 05 04:26 PM


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