Forum Discussion
bnhx
Sep 10, 2019Copper Contributor
Add a value to multiple cells in specific place in a column
I have a column of data formatted as 2019-Sep-09 07:00:00PM 2019-Sep-09 07:00:00PM 2019-Sep-09 07:00:00PM This format cannot be changed, but I am trying to add 10 to the minutes place, incr...
- Sep 10, 2019
To increment time by 10 Minutes, you may try the following macro...
In the attached, click the button called "Increment By 10 Minutes" on Sheet1 to increment Time in DateTime Stamp in column A.
The code assumes that all the DateTime stamps are same (as per your description) and it will take the first one and start adding 10 minutes to it and does the same for other values down the rows.
Sub IncrementDateTimeBy10Minutes() Dim dt As Date Dim lr As Long Application.ScreenUpdating = False 'Assuming DateTime strings are in column A lr = Cells(Rows.Count, "A").End(xlUp).Row dt = DateValue(Range("A2").Value) + TimeValue(Range("A2").Value) Range("A2").Value = dt dt = dt + TimeValue("00:10:00") Range("A3").Value = dt Range("A2:A3").AutoFill Destination:=Range("A2:A" & lr), Type:=xlFillDefault Range("A2:A10" & lr).NumberFormat = "yyyy-mmm-dd hh:mm:ss am/pm" Application.ScreenUpdating = True End Sub
Twifoo
Sep 10, 2019Silver Contributor
I believe you can achieve your desired results with a simple formula, like this in B2 of the attached file:
=MAX(A2,B1)+C$2
Note that C2 stores the required time increment.