Subtract from last occupied cel

poikl

Active Member
Joined
Jun 8, 2002
Messages
459
Please can you help me with this Time sheet problem?
I have Time Sheet with entries (In, Out, Break,etc) in Rows 1 thru 10in ColA. I'd like to show in ColB time diffrence between each. My Problem is that NOT all rows have entries, so it's possible that ColB Row8 will subtract ColA Row8 from ColA Row7 - IF IT'S OCCUPIED, if NOT the it should look further up and subtract from Row6 if THAT'S Occupied and if not then go furter up till the last occupied cell and then show the diffrence
 

Some videos you may like

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,379
<br /><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><colgroup><col width="25px" style="background-color: #E0E0F0" /><col /><col /></colgroup><thead><tr style=" background-color: #E0E0F0;text-align: center;color: #161120"><th></th><th>A</th><th>B</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style="text-align: right;;">8:00 AM</td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style="text-align: right;;">9:00 AM</td><td style="text-align: right;;">1:00</td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style="text-align: right;;"></td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style="text-align: right;;">11:00 AM</td><td style="text-align: right;;">2:00</td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style="text-align: right;;"></td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style="text-align: right;;"></td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style="text-align: right;;"></td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">8</td><td style="text-align: right;;"></td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">9</td><td style="text-align: right;;"></td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">10</td><td style="text-align: right;;">5:00 PM</td><td style="text-align: right;;">6:00</td></tr></tbody></table><br /><br /><table cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #A6AAB6"><thead><tr style=" background-color: #E0E0F0;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">B2</th><td style="text-align:left">=IF(<font color="Blue">A2="","",A2-A1</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">B3</th><td style="text-align:left">=IF(<font color="Blue">A3="","",A3-INDEX(<font color="Red">$A$1:A2,MATCH(<font color="Green">1,$A$1:A2,1</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">B4</th><td style="text-align:left">=IF(<font color="Blue">A4="","",A4-INDEX(<font color="Red">$A$1:A3,MATCH(<font color="Green">1,$A$1:A3,1</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">B5</th><td style="text-align:left">=IF(<font color="Blue">A5="","",A5-INDEX(<font color="Red">$A$1:A4,MATCH(<font color="Green">1,$A$1:A4,1</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">B6</th><td style="text-align:left">=IF(<font color="Blue">A6="","",A6-INDEX(<font color="Red">$A$1:A5,MATCH(<font color="Green">1,$A$1:A5,1</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">B7</th><td style="text-align:left">=IF(<font color="Blue">A7="","",A7-INDEX(<font color="Red">$A$1:A6,MATCH(<font color="Green">1,$A$1:A6,1</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">B8</th><td style="text-align:left">=IF(<font color="Blue">A8="","",A8-INDEX(<font color="Red">$A$1:A7,MATCH(<font color="Green">1,$A$1:A7,1</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">B9</th><td style="text-align:left">=IF(<font color="Blue">A9="","",A9-INDEX(<font color="Red">$A$1:A8,MATCH(<font color="Green">1,$A$1:A8,1</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">B10</th><td style="text-align:left">=IF(<font color="Blue">A10="","",A10-INDEX(<font color="Red">$A$1:A9,MATCH(<font color="Green">1,$A$1:A9,1</font>)</font>)</font>)</td></tr></tbody></table></td></tr></table>

Format column B as Time 13:30
 
Last edited:

poikl

Active Member
Joined
Jun 8, 2002
Messages
459
Alph, Thank you very much for your quick and excellent reply. Great help.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,577
Messages
5,596,996
Members
414,116
Latest member
sfullnet

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