automatically calculate the time from 2 separate cells with variable rows inbetween

mingandmong

Active Member
Joined
Oct 15, 2014
Messages
339
Hi
I'm using excel 2013
and require a macro to calculate my sheet with 2000 rows of data

I have a start time in column G row 2 and a finish time in column J row 7 and wish to calculate in Column O row 7

The data then has an empty row before starting on the next block of data

The start time is now in row 9 and the finish time is in row 14 and wish to calculate in Column O row 14

The source data is always in G/J with the result in column O all through the data sheet the blocks of data have variable rows

Many thanks
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Re: automaticaly calculate the time from 2 spertae cells with variable rows inbetween

I'm sure it can be done, but I'd need more info. Can you post your sheet?

Matt
 
Upvote 0
Re: automaticaly calculate the time from 2 spertae cells with variable rows inbetween

Is there anything else in column J besides the finish time for each block?

If so, I'd like to know more abot what is in each data block (eg G2:J6, G9:J14 etc)
 
Upvote 0
Re: automaticaly calculate the time from 2 spertae cells with variable rows inbetween

CVSJj6V
Hi Peter yes

not sure how to upload the code but its here

https://ibb.co/CVSJj6V

Code:
https://ibb.co/CVSJj6V
 
Last edited:
Upvote 0
Re: automaticaly calculate the time from 2 spertae cells with variable rows inbetween

Hi _Macrotect
I have included a link.. not sure how to imbed it
I have a new sheet every day and the rows change dependent on the data provided hope it helps to give you a general idea
 
Upvote 0
Re: automaticaly calculate the time from 2 spertae cells with variable rows inbetween

How about
Code:
Sub mingandmong()
   Dim Rng As Range
   
   For Each Rng In Range("G:G").SpecialCells(xlConstants).Areas
      Rng.Offset(Rng.Count - 1, 8).Resize(1, 1).Value = _
         Rng.Offset(Rng.Count - 1, 3).Resize(1, 1) - Rng.Resize(1, 1)
   Next Rng
End Sub
 
Last edited:
Upvote 0
Re: automaticaly calculate the time from 2 spertae cells with variable rows inbetween

Thank you Fluff

works perfect
 
Upvote 0
Re: automaticaly calculate the time from 2 spertae cells with variable rows inbetween

You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,442
Members
449,083
Latest member
Ava19

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