Userform textbox formatting

Linus_99

Board Regular
Joined
Aug 28, 2002
Messages
145
I am using a textbox on a userform to update a cell in a spreadsheet, & having some trouble with the formatting.

On the spreadsheet the cell with the control source is formatted as a time (e.g.08:00 am) while the textbox on the userform displays 0.33333.

On the userform, I can type in a formatted date such as 09:00 into the text box & this updates the spreadsheet correctly, but it's not a good look !

Any advice on how to format the textbox on the userform to show the time as 08:00 am would be appreciated.

Thanks,
 

Some videos you may like

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Fryer Tuck

Board Regular
Joined
Mar 20, 2002
Messages
64
I haven't worked as much with time, but I have solved my formatting problems by loading with the format

eg. TextBox = Format(Range("A1"),"0.00%")

Hope that helps
F.T.
 

Linus_99

Board Regular
Joined
Aug 28, 2002
Messages
145
Thanks F.T. but it doesn't seem to work.

I'm getting the control source cell position from a selected row in a text box, & then setting the control source by:

Tstart.ControlSource = "d" & Slist.ListIndex + 2

When I tried your suggested method to format Tstart, the control Tstart appeared correctly as 08:00 am in the text box on the form, but when I overtyped it with a new time value, the original cell in the worksheet was not updated.

Thanks anyway. Any other ideas ??
 

Fryer Tuck

Board Regular
Joined
Mar 20, 2002
Messages
64
Sounds like you are missing the command to update the sheet after the form is updated.
(Again, at this point, I have had to use the "format" equation, such as
Range("A1")=format(textbox1,"0.0%")
 

Linus_99

Board Regular
Joined
Aug 28, 2002
Messages
145
Thanks for your help F.T.

I added a BeforeUpdate sub with the "reverse formatting" you suggested and it now seems to be working fine.

[A complicated way to solve what appeared to be a simple formatting exercise !!!]
 

Watch MrExcel Video

Forum statistics

Threads
1,122,215
Messages
5,594,883
Members
413,947
Latest member
gizmolucy

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