If time value in Sheet 1 Col D >=2hrs then copy 4 cells in last row to Sheet 2 first empty row

Ironman

Well-known Member
Joined
Jan 31, 2004
Messages
1,069
Office Version
  1. 365
Platform
  1. Windows
Hi

Sheet 1 'Training Log' last row A:E is shown below:
Fri, 8 Oct 2021Cullingworth Rd/Haworth Rd/Flappit/L Halifax Rd/ Trough Ln/Denholme Rd/ Station Rd (Oxenhope)/ Moorhse Ln/R Marsh Ln (Haworth)/Sun St/ Bridgehouse Ln/Brow Rd Brow Top Rd/Hawrth Rd Turf Ln/Station Road/ Greenside Lane9.92:22:4114:25


Sheet 2 'Iron Man Log' A:D is shown below:
Fri 08/10/20219.92:22:4114:25


What I'm after is some code that is triggered when the value in Col D of the last row of Sheet 'Training Log' is greater than or equal to 2 hours. When that is identified, the values in the cells in Cols A, C, D & E of that row are copied to Cols A, B, C & D of the last row in Sheet 'Iron Man Log'.

If this can be done I'd be very grateful!

Thank you!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Resolved through trial and error.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 4 And Target.Row = Range("A" & Rows.Count).End(xlUp).Row Then
    Application.EnableEvents = False
    Lr1 = Target.Row
    If Sheets("Training Log").Range("D" & Lr1).Value >= 0.0833 Then
        Lr2 = Sheets("Iron Man Log").Range("A" & Rows.Count).End(xlUp).Row + 1
        Sheets("Iron Man Log").Range("A" & Lr2).Value = Sheets("Training Log").Range("A" & Lr1).Value
        Sheets("Iron Man Log").Range("B" & Lr2).Value = Sheets("Training Log").Range("C" & Lr1).Value
        Sheets("Iron Man Log").Range("C" & Lr2).Value = Sheets("Training Log").Range("D" & Lr1).Value
        Sheets("Iron Man Log").Range("D" & Lr2).Value = Sheets("Training Log").Range("E" & Lr1).Value
    Application.EnableEvents = True
    End If
End If
 
Upvote 0
Solution

Forum statistics

Threads
1,224,825
Messages
6,181,191
Members
453,021
Latest member
pingpong7117

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