VBA; find max time value in a column and add one minute to it

Range

Board Regular
Joined
Nov 13, 2010
Messages
140
Hey

Does anyone have any ideas on how to write a snippet of vba code to do the above?

Thanks,
Range
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hi,

Change the column to the correct one.


Code:
Dim TheColumn As String
TheColumn = "A"
Cells(Application.Match(Application.Max(Columns(TheColumn)), Columns(TheColumn), 0), TheColumn) = _
Cells(Application.Match(Application.Max(Columns(TheColumn)), Columns(TheColumn), 0), TheColumn) + TimeValue("00:1")
 
Last edited:
Upvote 0
wonderful, So I tried to change the above a little and failed. Not sure what I am doing wrong.

Code:
Sub Macro2()'
' Macro2 Macro
' Macro recorded
'


'
Dim TheColumn As String
TheColumn = "A"
Dim MyDate As Date


MyDate = TimeValue(Cells(Application.Match(Application.Max(Columns(TheColumn)), Columns(TheColumn), 0), TheColumn) = _
Cells(Application.Match(Application.Max(Columns(TheColumn)), Columns(TheColumn), 0), TheColumn) + TimeValue("00:01"))




Range("A78").Select
ActiveCell.Value = MyDate


End Sub
 
Upvote 0
Hi,

Try this

Code:
Sub Macro2() '

Dim TheColumn As String
TheColumn = "A"
Dim MyDate As Date
MyDate = Cells(Application.Match(Application.Max(Columns(TheColumn)), Columns(TheColumn), 0), TheColumn) + TimeValue("00:01")


Range("A78").Value = MyDate


End Sub
 
Upvote 0
Thank kindly good sir - this worked a treat and your taught me something as well!!
 
Upvote 0
Thank kindly good sir - this worked a treat and your taught me something as well!!

Glad that worked for you and thanks for the feedback. A day when you don't learn something new is a wasted day indeed.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,688
Members
448,978
Latest member
rrauni

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