how to add current time to an existing (static) date?

kbishop94

Active Member
Joined
Dec 5, 2016
Messages
458
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
my application/code:

Via a userform, the user enters data into several fields, one of which is a text box for a DATE to be entered.

When the user closes the form, the data from the form is posted over to the main worksheet.

here is my code for posting (and formatting) the date field from the form to the worksheet:
Code:
.Cells(10, lCol + 2).Value = Me.txtDateBox.Value
.Cells(10, lCol + 2).NumberFormat = "MM'/'dd'/'yyyy"

So over on the worksheet, in the specific cell listed above, it now looks like this:

14Date.PNG


Also when the data from the userform is moved over to the worksheet, another cell has whatever the current TIME happens to be placed into it (and formatted as shown):

the code for this:
Code:
With Cells(3, lCol + 2)
    .Value = Now()
    .Value = TimeValue(.Value)
    .NumberFormat = "h:mm:ss AM/PM"
End With

So out on the worksheet, and in the specific cell listed above, it looks like this:

15Date.PNG


here's my problem and my request:

I need to have the two cells listed above combined. The result of combining those 2 cells (the DATE cell in -> (10, lCol + 2), and the TIME cell in -> (3, lCol + 2) ) needs to look like the example shown below and placed into: (6, lCol + 1) .

The resulting cell in (6, lCol + 1) after being combined and formatted correctly needs to look like THIS:

12Date.PNG


Thank you in advance for the solution, or suggestions. :)
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
How about
VBA Code:
= CDate(Me.txtDateBox.Value) + TimeValue(Now)
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

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