retrieving multiple cells correlated with another cell

mike4777

Board Regular
Joined
Apr 12, 2011
Messages
122
I have a list of coins that are bought at different exchanges in Column A. The exchanges are listed in column B. Some coins are bought from 2 or more exchanges so there may be entries that look like this:

Coin AExchange 1
Coin BExchange 2
Coin AExchange 3

<tbody>
</tbody>

I've created a summary table that lists balances by coins and I'm trying to include the exchange a coin was purchased at. I don't think index/match will work. This is what I'm looking for:

Coin AExchange 1, Exchange 3
Coin BExchange 2

<tbody>
</tbody>

There may be several exchanges to be retrieved. Any ideas?

Thanks in advance :)
 
Last edited:

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
In B2 of Summary control+shift+enter, not just enter:

=TEXTJOIN(", ",1,IF(Data!$A$2:$A$4=$A2,$B$2:$B$4,""))

If TEXTJOIN is not available on your system, we can either a UDF (ACONCAT) to the same effect or place the results of each coin in cells of their own.
 
Upvote 0
In B2 of Summary control+shift+enter, not just enter:

=TEXTJOIN(", ",1,IF(Data!$A$2:$A$4=$A2,$B$2:$B$4,""))

If TEXTJOIN is not available on your system, we can either a UDF (ACONCAT) to the same effect or place the results of each coin in cells of their own.

I don't understand how the formula plugs in. The B column above has nothing in it yet... this is where the formula I'm asking for will go to retrieve the exchanges. I have another sheet with all the coins and the exchanges they were bought at (coins in column B and exchanges in column G). The tab the data is on is "Trades"
 
Last edited:
Upvote 0
Summary Tab:

Coinformula to retrieve exchanges

<tbody>
</tbody>


Trades Tab (where the raw data is):

Column BColumn G
Coin AExchange 1
Coin BExchange 2
Coin AExchange 3

<tbody>
</tbody>
 
Upvote 0
Summary Tab:

Coinformula to retrieve exchanges

<tbody>
</tbody>


Trades Tab (where the raw data is):

Column BColumn G
Coin AExchange 1
Coin BExchange 2
Coin AExchange 3

<tbody>
</tbody>

In B2 of Summary control+shift+enter, not just enter:

=TEXTJOIN(", ",1,IF(Trades!$A$2:$A$4=$A2,Trades$B$2:$B$4,""))

If TEXTJOIN is not available on your system, we can either a UDF (ACONCAT) to the same effect or place the results of each coin in cells of their own.
 
Upvote 0
In B2 of Summary control+shift+enter, not just enter:

=TEXTJOIN(", ",1,IF(Trades!$A$2:$A$4=$A2,Trades$B$2:$B$4,""))

If TEXTJOIN is not available on your system, we can either a UDF (ACONCAT) to the same effect or place the results of each coin in cells of their own.


Did you mean
Code:
=TEXTJOIN(", ",1,IF(Trades!$B$2:$B$1003=$A2,Trades!$G$2:$G$1003,""))

I'm getting a name error. I am entering it as an array like you said.
 
Upvote 0
That means the native TEXTJOIN function is not available on your Excel.

In B2 of Summary control+shift+enter, not just enter, and copy down:
Rich (BB code):
=REPLACE(aconcat(IF(Trades!$A$2:$A$4=$A2,", "&Trades!$B$2:$B$4,"")),1,2,"")

where A2 = Coin A.


For this formula to work, add the following code for ACONCAT as a Module to your workbook using Alt+F11...

Function aconcat(a As Variant, Optional sep As String = "") As String
' Harlan Grove, Mar 2002
Dim y As Variant
If TypeOf a Is Range Then
For Each y In a.Cells
aconcat = aconcat & y.Value & sep
Next y
ElseIf IsArray(a) Then
For Each y In a
aconcat = aconcat & y & sep
Next y
Else
aconcat = aconcat & a & sep
End If
aconcat = Left(aconcat, Len(aconcat) - Len(sep))
End Function


If you don't want a udf (ACONCAT is a udf), then:

In B2 of Summary, control+shift+enter, not just enter, copy across, and down:
Rich (BB code):
=IFERROR(INDEX($B$2:$B$4,SMALL(IF($A$2:$A$4=$A2,ROW(
$B$2:$B$4
)-ROW(
$B$2)+1),ROWS($B2:B2))),"")

<strike></strike><strike></strike>
 
Upvote 0
That means the native TEXTJOIN function is not available on your Excel.

In B2 of Summary control+shift+enter, not just enter, and copy down:
Rich (BB code):
=REPLACE(aconcat(IF(Trades!$A$2:$A$4=$A2,", "&Trades!$B$2:$B$4,"")),1,2,"")

where A2 = Coin A.


For this formula to work, add the following code for ACONCAT as a Module to your workbook using Alt+F11...

Function aconcat(a As Variant, Optional sep As String = "") As String
' Harlan Grove, Mar 2002
Dim y As Variant
If TypeOf a Is Range Then
For Each y In a.Cells
aconcat = aconcat & y.Value & sep
Next y
ElseIf IsArray(a) Then
For Each y In a
aconcat = aconcat & y & sep
Next y
Else
aconcat = aconcat & a & sep
End If
aconcat = Left(aconcat, Len(aconcat) - Len(sep))
End Function


If you don't want a udf (ACONCAT is a udf), then:

In B2 of Summary, control+shift+enter, not just enter, copy across, and down:
Rich (BB code):
=IFERROR(INDEX($B$2:$B$4,SMALL(IF($A$2:$A$4=$A2,ROW(
$B$2:$B$4
)-ROW(
$B$2)+1),ROWS($B2:B2))),"")

<strike></strike><strike></strike>



The code appears to be working but it is pulling duplicates the same exchange. Is there a way to get rid of this? Also, on cells where there isn't a coin listed yet it is displaying ",,,,,,,,,,,,,,,,,,,,,,,,,," How can I get rid of this?
 
Last edited:
Upvote 0
The code appears to be working but it is pulling duplicates the same exchange. Is there a way to get rid of this? Also, on cells where there isn't a coin listed yet it is displaying ",,,,,,,,,,,,,,,,,,,,,,,,,," How can I get rid of this?

Thus you have

coin a, exchange 1
coin b, exchange 1
coin a, exchange 2
coin a, exchange 1

Otherwise, yo won't get duplicates...
 
Upvote 0
No, I am getting results like:

Exchange A, Exchange B, Exchange A
Exchange A, Exchange A

I only want each unique exchange displayed once. Also, how do I suppress the commas?

Remember, I may have the same coin put in the data column twice and it may have the same exchange displayed by each coin.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,746
Messages
6,126,641
Members
449,325
Latest member
Hardey6ix

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top