Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Userform formatting


I have a UserForm textbox point to a cell on a sheet. The cell is date
formated to dd-mmm-yyyy but the test box seems to default to m/d/yyyy unless
m 12 then the format changes to d/m/yyy. Is it possible to change the date
format on the Userform or make it obey the sheet formatting?

--
Trefor
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Userform formatting

break the assignment of controlsource and
load the textbox with code. Then you can format it just like the cell

Private Sub Userform_Initialize()
Textbox1.Value = worksheets("Sheet1").Range("A1").Text
End Sub

--
Regards,
Tom Ogilvy


"Trefor" wrote:


I have a UserForm textbox point to a cell on a sheet. The cell is date
formated to dd-mmm-yyyy but the test box seems to default to m/d/yyyy unless
m 12 then the format changes to d/m/yyy. Is it possible to change the date
format on the Userform or make it obey the sheet formatting?

--
Trefor

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Userform formatting

Tom,

Thanks for the reply, that does indeed fix one problem but breaks another. I
would like to edit the text box on the userform and have it update the cell
on the spreedsheet. Now that I have made you selected change it does not
update the cell anymore. Sorry I am new to Userforms so this is probably
really simple!

--
Trefor


"Tom Ogilvy" wrote:

break the assignment of controlsource and
load the textbox with code. Then you can format it just like the cell

Private Sub Userform_Initialize()
Textbox1.Value = worksheets("Sheet1").Range("A1").Text
End Sub

--
Regards,
Tom Ogilvy


"Trefor" wrote:


I have a UserForm textbox point to a cell on a sheet. The cell is date
formated to dd-mmm-yyyy but the test box seems to default to m/d/yyyy unless
m 12 then the format changes to d/m/yyy. Is it possible to change the date
format on the Userform or make it obey the sheet formatting?

--
Trefor

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Userform formatting

You would use the event code of the textbox and write the change back to the
sheet.

Private Sub TextBox1_Change()
Dim dt As Date, rng As Range
Set rng = Worksheets("Sheet1").Range("A1")
If IsDate(TextBox1.Text) Then
On Error Resume Next
dt = CDate(TextBox1.Text)
rng.Value = dt
On Error GoTo 0
End If
End Sub

this would go in the userform module.
--
Regards,
Tom Ogilvy


"Trefor" wrote:

Tom,

Thanks for the reply, that does indeed fix one problem but breaks another. I
would like to edit the text box on the userform and have it update the cell
on the spreedsheet. Now that I have made you selected change it does not
update the cell anymore. Sorry I am new to Userforms so this is probably
really simple!

--
Trefor


"Tom Ogilvy" wrote:

break the assignment of controlsource and
load the textbox with code. Then you can format it just like the cell

Private Sub Userform_Initialize()
Textbox1.Value = worksheets("Sheet1").Range("A1").Text
End Sub

--
Regards,
Tom Ogilvy


"Trefor" wrote:


I have a UserForm textbox point to a cell on a sheet. The cell is date
formated to dd-mmm-yyyy but the test box seems to default to m/d/yyyy unless
m 12 then the format changes to d/m/yyy. Is it possible to change the date
format on the Userform or make it obey the sheet formatting?

--
Trefor

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Userform formatting

Tom,

You have been very helpful thankyou very much.

--
Trefor


"Tom Ogilvy" wrote:

You would use the event code of the textbox and write the change back to the
sheet.

Private Sub TextBox1_Change()
Dim dt As Date, rng As Range
Set rng = Worksheets("Sheet1").Range("A1")
If IsDate(TextBox1.Text) Then
On Error Resume Next
dt = CDate(TextBox1.Text)
rng.Value = dt
On Error GoTo 0
End If
End Sub

this would go in the userform module.
--
Regards,
Tom Ogilvy


"Trefor" wrote:

Tom,

Thanks for the reply, that does indeed fix one problem but breaks another. I
would like to edit the text box on the userform and have it update the cell
on the spreedsheet. Now that I have made you selected change it does not
update the cell anymore. Sorry I am new to Userforms so this is probably
really simple!

--
Trefor


"Tom Ogilvy" wrote:

break the assignment of controlsource and
load the textbox with code. Then you can format it just like the cell

Private Sub Userform_Initialize()
Textbox1.Value = worksheets("Sheet1").Range("A1").Text
End Sub

--
Regards,
Tom Ogilvy


"Trefor" wrote:


I have a UserForm textbox point to a cell on a sheet. The cell is date
formated to dd-mmm-yyyy but the test box seems to default to m/d/yyyy unless
m 12 then the format changes to d/m/yyy. Is it possible to change the date
format on the Userform or make it obey the sheet formatting?

--
Trefor

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
Conditional formatting and userform jknapp1005 Excel Discussion (Misc queries) 0 May 6th 09 04:53 PM
Formatting userform textbox - help required Kennyatwork Excel Programming 3 February 6th 04 04:58 PM
Formatting number in a UserForm TextBox John Pierce Excel Programming 3 January 26th 04 04:57 PM
Userform/Cell formatting Todd Huttenstine Excel Programming 2 September 28th 03 11:16 PM
Userform Formatting Todd Huttenstine Excel Programming 7 September 28th 03 09:36 PM


All times are GMT +1. The time now is 11:54 AM.

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

About Us

"It's about Microsoft Excel"