Returning last value in cell based on value of another cell

VBAhelp33

New Member
Joined
Sep 13, 2020
Messages
11
Office Version
  1. 2019
Platform
  1. Windows
Hi all,

I am trying to create a formula that will return the values that are highlighted in red in the below screenshot but am not having much luck. Basically, I would like to return the previous transaction value for that particular stock. If there has been no previous transactions for that stock, I'd like the cell to be blank & if I have purchased the stock in the past, I'd like the cell to return the last transaction value for that particular stock.

Does anyone have any ideas how I can do this?

1611656894017.png
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Phuoc

Active Member
Joined
Apr 29, 2016
Messages
320
Try this in cell G2:

=IFERROR(LOOKUP(2,1/($B$1:B1="buy")/($C$1:C1=C2),$F$1:F1),"")
 

Watch MrExcel Video

Forum statistics

Threads
1,130,197
Messages
5,640,795
Members
417,166
Latest member
Funwayo

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
Top