Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Date format from UserForm


Hi All,

I have a very simple UserForm with 4 textboxes and an OK Button on it.

One of the textboxes is for a date which is inputted to the sheet on
clicking OK with the following code:

Private Sub cmdOK_Click()

ActiveCell.Value = tbxDate.Value
ActiveCell.Offset(0, 1).Value = tbxSupplier.Value
ActiveCell.Offset(0, 2).Value = tbxInvoiceTotal.Value
ActiveCell.Offset(0, 3).Value = tbxExtras.Value

End Sub

My difficulty is that if the date is put into the form in the format
dd/mm/yyyy the above code puts it into the active cell in that format.
But I really want the format to be dd-mmm-yyyy. Even if after the form
has been used I try to apply that format to the cell it remains as
dd/mm/yyyy.

If I input the date on the actual sheet as dd/mm/yyyy the format
changes to dd-mmm-yyyy.

Any advice wold be appreciated

Seamus


--
SOS
------------------------------------------------------------------------
SOS's Profile: http://www.excelforum.com/member.php...fo&userid=5406
View this thread: http://www.excelforum.com/showthread...hreadid=513168

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Date format from UserForm

ActiveCell.Value = cDate(tbxDate.Value)
ActiveCell.NumberFormat = "dd-mmm-yyyy"
ActiveCell.Offset(0, 1).Value = tbxSupplier.Value
ActiveCell.Offset(0, 2).Value = tbxInvoiceTotal.Value
ActiveCell.Offset(0, 3).Value = tbxExtras.Value

--
Regards,
Tom Ogilvy


"SOS" wrote in message
...

Hi All,

I have a very simple UserForm with 4 textboxes and an OK Button on it.

One of the textboxes is for a date which is inputted to the sheet on
clicking OK with the following code:

Private Sub cmdOK_Click()

ActiveCell.Value = tbxDate.Value
ActiveCell.Offset(0, 1).Value = tbxSupplier.Value
ActiveCell.Offset(0, 2).Value = tbxInvoiceTotal.Value
ActiveCell.Offset(0, 3).Value = tbxExtras.Value

End Sub

My difficulty is that if the date is put into the form in the format
dd/mm/yyyy the above code puts it into the active cell in that format.
But I really want the format to be dd-mmm-yyyy. Even if after the form
has been used I try to apply that format to the cell it remains as
dd/mm/yyyy.

If I input the date on the actual sheet as dd/mm/yyyy the format
changes to dd-mmm-yyyy.

Any advice wold be appreciated

Seamus


--
SOS
------------------------------------------------------------------------
SOS's Profile:

http://www.excelforum.com/member.php...fo&userid=5406
View this thread: http://www.excelforum.com/showthread...hreadid=513168



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Date format from UserForm


Thanks to both Toppers and Tom - both solutions work well.

Thanks Again

Seamus


--
SOS
------------------------------------------------------------------------
SOS's Profile: http://www.excelforum.com/member.php...fo&userid=5406
View this thread: http://www.excelforum.com/showthread...hreadid=513168

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Date format from UserForm

Try this ... (dates are real pain!):

ActiveCell.Value = Format(CDate(tbxDate.Text), "dd-mmm-yyyy")

"SOS" wrote:


Hi All,

I have a very simple UserForm with 4 textboxes and an OK Button on it.

One of the textboxes is for a date which is inputted to the sheet on
clicking OK with the following code:

Private Sub cmdOK_Click()

ActiveCell.Value = tbxDate.Value
ActiveCell.Offset(0, 1).Value = tbxSupplier.Value
ActiveCell.Offset(0, 2).Value = tbxInvoiceTotal.Value
ActiveCell.Offset(0, 3).Value = tbxExtras.Value

End Sub

My difficulty is that if the date is put into the form in the format
dd/mm/yyyy the above code puts it into the active cell in that format.
But I really want the format to be dd-mmm-yyyy. Even if after the form
has been used I try to apply that format to the cell it remains as
dd/mm/yyyy.

If I input the date on the actual sheet as dd/mm/yyyy the format
changes to dd-mmm-yyyy.

Any advice wold be appreciated

Seamus


--
SOS
------------------------------------------------------------------------
SOS's Profile: http://www.excelforum.com/member.php...fo&userid=5406
View this thread: http://www.excelforum.com/showthread...hreadid=513168


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Format for Userform TextBox John Calder New Users to Excel 4 July 29th 09 10:19 PM
Date format in userform cutsygurl Excel Programming 3 April 19th 06 09:44 AM
Restrict date format for UserForm Rob Excel Discussion (Misc queries) 2 December 19th 05 12:13 AM
Qn: Date Format in TextBox in UserForm? Michael Vaughan Excel Programming 1 August 23rd 04 10:03 AM
Userform date format problem jennie Excel Programming 2 July 30th 04 01:49 PM


All times are GMT +1. The time now is 08:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"