Timevalue with specific date

becklog

New Member
Joined
Dec 26, 2016
Messages
38
Hi,
I need some help with the code below. Would it be possible to add a date on this code?
I tried to format the cells to mm/dd/yyyy hh:mm but it's not working as intended. When I ran the macro, it will ignore the date that was set and will just follow the time set. Is there anyway to add a date to this macro? Thanks!
Private Sub Second()
Application.OnTime TimeValue(Range("A1").Text), "Test1"
Application.OnTime TimeValue(Range("A2").Text), "Test2"
Application.OnTime TimeValue(Range("A3").Text), "Test3"
Application.OnTime TimeValue(Range("A4").Text), "Test4"
Application.OnTime TimeValue(Range("A5").Text), "Test5"
Application.OnTime TimeValue(Range("A6").Text), "Test6"
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hi,
I need some help with the code below. Would it be possible to add a date on this code?
I tried to format the cells to mm/dd/yyyy hh:mm but it's not working as intended. When I ran the macro, it will ignore the date that was set and will just follow the time set. Is there anyway to add a date to this macro? Thanks!
Private Sub Second()
Application.OnTime TimeValue(Range("A1").Text), "Test1"
Application.OnTime TimeValue(Range("A2").Text), "Test2"
Application.OnTime TimeValue(Range("A3").Text), "Test3"
Application.OnTime TimeValue(Range("A4").Text), "Test4"
Application.OnTime TimeValue(Range("A5").Text), "Test5"
Application.OnTime TimeValue(Range("A6").Text), "Test6"

I think I found the answer.
 
Upvote 0
Care to share this answer you found?

Just found out that other than TimeValue there is also DateValue which allows you to set a specific date for the command to execute.

Application.OnTime DateValue (Range("A2").Text) + TimeValue(Range("A1").Text), "Test1"
 
Upvote 0

Forum statistics

Threads
1,214,402
Messages
6,119,301
Members
448,885
Latest member
LokiSonic

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