Forum Discussion
Add a value to multiple cells in specific place in a column
- 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
bnhx ,
Please try the following formula.
= IFERROR(DATE(LEFT(A2:A30,4), MONTH(1&MID(A2:A30,6,3)),MID(A2:A30,10,2))+TIMEVALUE(MID(A2:A30,13,8)&" "&RIGHT(A2:A30,2))+TIME(0,10*(ROW(A2:A30)-1),0),"")
Also attached is a sample.
This formula converts input string in to a Date/Time serial number and keeps adding Row*10 minutes.
This formula assumes that the input data is in range A2:A30. If there is a change you need to update formula for revised range.
ROW(A2:A20)-1) - this component is a row dependent function. if your starting row is N, you need to do ROW(A2:A20)-(N-1)) to get the right row number.
hope it works for you!!