Column in table based on previous rows

Mr. Snrub

Board Regular
Joined
May 22, 2005
Messages
150
Office Version
  1. 365
Platform
  1. Windows
Here is what my Excel spreadsheet formatted as a table looks like:

<table>
<tr>
<th>Date</th>
<th>Month Name</th>
<th>Trading Day</th>
</tr>
<tr>
<td>12/1/2017</td>
<td>12</td>
<td>TRUE</td>
</tr>
<tr>
<td>12/2/2017</td>
<td>12</td>
<td>FALSE</td>
</tr>
<tr>
<td>12/3/2017</td>
<td>12</td>
<td>FALSE</td>
</tr>
<tr>
<td>12/4/2017</td>
<td>12</td>
<td>TRUE</td>
</tr>
<tr>
<td>1/1/2018</td>
<td>1</td>
<td>FALSE</td>
</tr>
<tr>
<td>1/2/2018</td>
<td>1</td>
<td>TRUE</td>
</tr>
<tr>
<td>1/3/2018</td>
<td>1</td>
<td>TRUE</td>
</tr>
</table>

I want to add a new column called "Monthly Trading Day Number" that will give the trading day number for the current month if "Trading Day" is equal to TRUE. So the counter will reset as you get to a new month. Like so:

<table>
<tr>
<th>Date</th>
<th>Month Name</th>
<th>Trading Day</th>
<th>Monthly Trading Day Number</th>
</tr>
<tr>
<td>12/1/2017</td>
<td>12</td>
<td>TRUE</td>
<td>1</td>
</tr>
<tr>
<td>12/2/2017</td>
<td>12</td>
<td>FALSE</td>
<td>-1</td>
</tr>
<tr>
<td>12/3/2017</td>
<td>12</td>
<td>FALSE</td>
<td>-1</td>
</tr>
<tr>
<td>12/4/2017</td>
<td>12</td>
<td>TRUE</td>
<td>2</td>
</tr>
<tr>
<td>1/1/2018</td>
<td>1</td>
<td>FALSE</td>
<td>-1</td>
</tr>
<tr>
<td>1/2/2018</td>
<td>1</td>
<td>TRUE</td>
<td>1</td>
</tr>
<tr>
<td>1/3/2018</td>
<td>1</td>
<td>TRUE</td>
<td>2</td>
</tr>
</table>



How do I do this?
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,225,746
Messages
6,186,791
Members
453,371
Latest member
HMX180

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