Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Would like to subtract 2 days from a date and set up time to 12 00,how to? hi al

ID: 3566934 • Letter: W

Question

Would like to subtract 2 days from a date and set up time to 12 00,how to?

hi all,,,

I came to maybe simple problem, but didnt find an answer on the internet.

Let say I have cell with day and time.

I am writing a macro which should change that cell. Change should be days minus 2 and time to be set up at 12 00. Is it possible somehow?

I tried combine to combine DateValue and TimeValue,...but no success

Sub time()
Dim y As Date
Dim x As Double

y = DateValue("C4"") - 2
x = TimeValue("12:00:00")

Range("C10") = yx

End Subb!

11/5/2014 14:13

Explanation / Answer

Hi,,,

try

You were close, try this

Sub time()
Dim y As Date
Dim x As Double

y = DateValue(Range("C4")) - 2
x = TimeValue("12:00:00")

Range("C10") = y + x

End Subb!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote