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
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
- bnhxSep 10, 2019Copper ContributorThank you for your assistance!
- Subodh_Tiwari_sktneerSep 10, 2019Silver Contributor
You're welcome! Glad I could help.