Determine Date Range

rwmill9716

Active Member
Joined
May 20, 2006
Messages
495
Office Version
  1. 2013
Platform
  1. Windows
I have a table that extends several thousand rows. I've included an image showing what I'm trying to do. Cols A and D are trade entry and exit dates; Col B is a unique symbol for a sequence of trades; Col C marks the beginning of the trade with an "*". I need a formula for Col E which calculates the number of days in the trade. Using A_2 as an example, the Days in the Trade would be the Max date for that symbol in Col D minus the Min date for that symbol in Col B; here, that's 8/20/24 - 2/1/24 or 201 days. Note, in the real spread sheet, the symbols will be mixed over a wide range of rows; I'm only interested in presenting the Days in Trade for rows housing an "*".
 

Attachments

  • Excel Table.jpg
    Excel Table.jpg
    32.3 KB · Views: 9

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Note, I'm using EXCEL 2013 so I don't have access to the MaxIFs function.
 
Upvote 0
Try:

Book1
ABCDE
1Date StartSYMBOLTrade BeginDay EndDays in Trade
21/1/2024A_1*1/2/202419
31/5/2024A_11/15/2024 
41/10/2024A_11/20/2024 
52/5/2024B_1*4/5/2024126
63/5/2024B_16/10/2024 
72/1/2024A_2*2/1/2024201
82/16/2024A_28/20/2024 
92/17/2024A_22/25/2024 
106/5/2024A_27/25/2024 
Sheet6
Cell Formulas
RangeFormula
E2:E10E2=IF(C2="*",MAX(IF($B$2:$B$10=B2,$D$2:$D$10))-MIN(IF($B$2:$B$10=B2,$A$2:$A$10)),"")
Press CTRL+SHIFT+ENTER to enter array formulas.


Note that this is an array formula. You need to enter it using Control+Shift+Enter, not just enter.
 
Upvote 0
Solution

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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