Seeking help to sum up certain data

abberyfarm

Well-known Member
Joined
Aug 14, 2011
Messages
733
Hi there,


I have data for car journeys. Would anybody be able to help me out with a macro to calculate the remaining distance to travel for that date in Column G. Here is an example:

Excel Workbook
ABCDEFG
1start_datestart_timeend_dateend_timeTypeTrip distanceRemaining distance to travel
204/01/201208:19:5204/01/201208:32:41T3.810
305/01/201208:13:1105/01/201208:23:39T3.8215.94
405/01/201217:45:2905/01/201217:50:19T1.2614.68
505/01/201218:05:4505/01/201218:16:56T3.6611.02
605/01/201218:43:3205/01/201219:00:17T8.522.5
705/01/201219:10:0605/01/201219:16:35T2.50
Sheet1


Many thanks

John
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
try this

Code:
Sub TripRemaining()
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row + 1

SR = ActiveCell.Address
Range(SR).FormulaR1C1 = "=SUM(R[1]C[-1]:R" & LR & "C6)"
Range(SR).Copy Destination:=Range(SR & ":G" & LR - 1)

End Sub

note: this code is intended for the cursor to be in cell G3 when ran.
 
Upvote 0

Forum statistics

Threads
1,214,884
Messages
6,122,082
Members
449,064
Latest member
MattDRT

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