DateAdd function in VBA

Sake14

New Member
Joined
Nov 12, 2013
Messages
6
Hello to all,

I am trying to add five hours to my date and time. I have together the time and date data in a cell in excel format.
I want to add five hours at each one of them and I am using the next formula but nothing happens ("H" is the column in which I have the Date and Time)
Any help please because I have to deliver that by tonight for my job:

Sub ForNextLoop()
Dim x As Integer
For x = 2 To Cells(2, "H").End(xlDown).Row - 1
Cells(x, "H") = DateAdd("h", 5, Cells(x, "H"))
Next
End Sub

Thanks a lot!!
 
in the vba window, when you step the code, you can hover over the variables and their values will be displayed as the code is executed
it can be handy when you cant see whats going on in a sub
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,215,528
Messages
6,125,342
Members
449,218
Latest member
Excel Master

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