Select range based on time.

powersp68232

New Member
Joined
Apr 24, 2018
Messages
12
I have data like the image below. I am trying to select a range from Cell B7 to Cell B908, Do Something, Select range B909 to B1807, Do Something, and continue this loop until I get to the last row of data. The cycle runs about 45sec each time, but there are always multiple instances of the time stamp. So, I am needing to be able to select the last row with that timestamp and then create a loop to complete the same on each cycle.

Ex.
VBA Code:
Private Sub Find_Range_Time()

Dim sTime As Range, fTime As Range, Total As Integer, LastRow As Long

'Set range with initial start time.
sTime = Range("B7")

'Find last cell with Finish Time
'This should locate the last cell that contains the finish time of the current cycle
'All cycles are 45 seconds

<code here>

'Do this loop on current cycle range
Total = (LastRow / 45) / 20
i = 1

For i = i To LastRow
Set Chart = Range("C" & sTime, "C" & fTime)

'Set sTime to cell fTime with offset of 1

sTime = fTime.Offset(1, 0)
Next i

End Sub

Data.gif
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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