Index for unique values and then loop through the result to calculate DCA

cyiton

New Member
Joined
Oct 3, 2021
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
I have notable Powershell experience, but I haven't played with VB in over a decade and I don't do much with Excel, so while I'm sure I could figure this out on my own, and I may need too, I figure this might be a common enough scenario where someone might have an elegant solution I can tweak and save myself a bunch of time.

What I'm looking to do is generate a DCA (Dollar cost average) list from a collection of transactions; so I'm looking to grab all the unique ticker values from one column (D) and for each unique value, add up the dollar amounts for it (from column C) and then divide by the share counts (column F); then output the ticker and the DCA value to a seperate set of cells.
Anyone have anything roughly in line with that?

Here's an example table:
Purchase History
for purchases with fiat
datePrice paid (in local fiat)Coin Bought/sold (insert ticker symbol)Amount of coins bought/sold (crypto)
31-May-19​
500​
ltcLitecoin
3​
2-Jun-20​
1000​
btcBitcoin
0.03​
8-Jun-20​
100​
btcBitcoin
0.025​
14-Jun-20​
100​
btcBitcoin
0.0018​
22-Jun-20​
100​
ethEthereum
0.1​
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Are you sure a pivot won't do what you need ?

Book1
HIJKL
1TickerPrice PaidCoins bought/sold (crypto)Sum of Value / Qty
2btc12000.056821,126.76
3eth1000.11,000.00
4ltc5003166.67
5Grand Total18003.1568570.20
6
Sheet1


Your data as XL2BB if anyone else wants to offer a solution.

Book1
ABCDEFG
1datePrice paid (in local fiat)Coin Bought/sold (insert ticker symbol)NameAmount of coins bought/sold (crypto)
231-May-19500ltcLitecoin3
32-Jun-201000btcBitcoin0.03
48-Jun-20100btcBitcoin0.025
514-Jun-20100btcBitcoin0.0018
622-Jun-20100ethEthereum0.1
7
Sheet1
 
Upvote 0

Forum statistics

Threads
1,214,382
Messages
6,119,194
Members
448,874
Latest member
Lancelots

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