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

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Mike LH

Well-known Member
Joined
Mar 17, 2015
Messages
566
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

Range

Board Regular
Joined
Nov 13, 2010
Messages
140
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

Mike LH

Well-known Member
Joined
Mar 17, 2015
Messages
566
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

Range

Board Regular
Joined
Nov 13, 2010
Messages
140
Thank kindly good sir - this worked a treat and your taught me something as well!!
 
Upvote 0

Mike LH

Well-known Member
Joined
Mar 17, 2015
Messages
566
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,195,855
Messages
6,011,973
Members
441,658
Latest member
Carlos O

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
Top