Hi there, I am trying to format a textbox value which shows as a number in a textbox as time i.e. 0.5 will show as 12:00. Any ideas?
Hi there, I am trying to format a textbox value which shows as a number in a textbox as time i.e. 0.5 will show as 12:00. Any ideas?
Maybe something like textbox('xyz").value = format(0.5, "hh:mm")?
The value won't always be 0.5. It will change.
Change 0.5 to textboxname.Value
For example.
Please Login or Register to view this content.
If posting code please use code tags, see here.
Just tried that but unfortunately it does not work. No error message though. This is the code I used:-
Please Login or Register to view this content.
Does Reg11.Value have a value in it?
yes it does 0.5. Tried the code by attaching it to a different event and it worked. It just does not work on the Userform_intialize() event?
Last edited by forrestgump1980; 03-23-2015 at 12:14 PM.
How/when is the textbox being populated with 0.5?
What events did you try?
the text box is populated with 0.5 when opening the userform as it is linked to a cell in excel. When I attached the code to another button it worked, but it still won't work on Userform_intialize() event.
Is the cell it's linked to formatted as hh:mm?
yes it is as well
If you want a value on a spreadsheet to appear in a textbox as it's formatted on the sheet remove the cell link and add this to the Initialize event, change Sheets("Sheet1").Range("A10") to the relevant sheet and cell.
Please Login or Register to view this content.
Thanks for your help with this. I think you have got me going in the right direction and I think it is because sometimes i refer to the value as .value and sometimes .text. I will experiment a little more tonight and let you know how I get on. Thanks once again.
I think the problem you are encountering might have something to do with the textbox being linked to a cell.
When you do that it's the underlying value in the cell that will appear in the textbox.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks