Display time & dates seperately in textboxes

karkas

Board Regular
Joined
Oct 17, 2007
Messages
165
Office Version
  1. 2013
Platform
  1. Windows
Rich (BB code):
Private Sub UserForm_Activate()
TextBox2.Value = Worksheets("Printing").Range("J23").Value
TextBox3.Value = Worksheets("Printing").Range("J24").Value
End Sub

J23 is currently formatted to diplay the date only from B8.
J24 is currently formatted to display the time only from B8.

When the user form is generated I want textbox2 to diplay only the date from B8.
When the user form is generated I want textbox3 to diplay only the time from B8.

How can I do this? The info plugged into textbox 2 & 3 will only show time and dates such as 11/23/2009 4:00:00 PM and 40140.6666666667 instead of what I want (11/23/09 & 16:00).

Does this make sense? Anyone able to help?

Thanks in advance
 

Some videos you may like

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Tom Urtis

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,224
A few ways to go about this, but essentially since you only care about what is in cell B8, cells J23 and J24 are superfluous for the purpose of populating your textboxes.

This should do it in your Activate or Initialize events:

Code:
With Worksheets("Printing").Range("B8")
TextBox2.Value = Format(.Value, "mm/dd/yy")
TextBox3.Value = Format(.Value, "hh:mm")
End With
 

karkas

Board Regular
Joined
Oct 17, 2007
Messages
165
Office Version
  1. 2013
Platform
  1. Windows
A few ways to go about this, but essentially since you only care about what is in cell B8, cells J23 and J24 are superfluous for the purpose of populating your textboxes.

This should do it in your Activate or Initialize events:

Code:
With Worksheets("Printing").Range("B8")
TextBox2.Value = Format(.Value, "mm/dd/yy")
TextBox3.Value = Format(.Value, "hh:mm")
End With

Thanks!

I'm gunna try it anotherway I just figured out without the ":" in the format "hh:mm". I simply rounded down in another cell B8 to 0 decimals, then subtracted that from B8.

You way is definately more eligant than mine though.

You guys are amazing
 

Watch MrExcel Video

Forum statistics

Threads
1,122,334
Messages
5,595,567
Members
413,996
Latest member
mabelO

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
Top