ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   UserForm TextBox/ComboBox question (https://www.excelbanter.com/excel-discussion-misc-queries/11091-userform-textbox-combobox-question.html)

grasping@straws

UserForm TextBox/ComboBox question
 
Is there any way to control the format in UserForm controls (like
there is in cells) to accomplish a WYSIWYG setup?
The "problem" is like this; I set up a combobox on a form to select a
date in mm/dd/yy format - the data comes from a range of cells
formatted to show dates ("TODAY()", TODAY+1", etc.) formatted as
"mm/dd/yy" & the cell the selection is written to is also formatted
the same...yet the ComboBox on the form shows the 5-digit Excel date
code until the focus shifts off the ComboBox, then shows the form
mm/dd/yyyy (& additionally drops preceeding zeroes) - even though the
format is correct in the destination cell once the UserForm is closed.
What I'm trying to avoid is confusion in the minds of some of the
folks who will be using this workbook...not all of them are especially
bright nor computer-literate. TIA.

tm

Bob Phillips

I presume that you have a link to the worksheet cells and pick up those
values automatically. I am afraid that if you want the dates formatted, you
will need to manually load them, something like

With Me.Combobox1
.AddItem ActiveSheet.Range("A1").Text
.AddItem ActiveSheet.Range("2").Text
'etc.
End With

if the worksheet dates are already formatted, or

With Me.Combobox1
.AddItem Format(ActiveSheet.Range("A1").Value,"mm/dd/yyyy")
.AddItem Format(ActiveSheet.Range("A2").Value,"mm/dd/yyyy")
'etc.
End With

if they are not

--

HTH

RP
(remove nothere from the email address if mailing direct)


"grasping@straws" wrote in message
...
Is there any way to control the format in UserForm controls (like
there is in cells) to accomplish a WYSIWYG setup?
The "problem" is like this; I set up a combobox on a form to select a
date in mm/dd/yy format - the data comes from a range of cells
formatted to show dates ("TODAY()", TODAY+1", etc.) formatted as
"mm/dd/yy" & the cell the selection is written to is also formatted
the same...yet the ComboBox on the form shows the 5-digit Excel date
code until the focus shifts off the ComboBox, then shows the form
mm/dd/yyyy (& additionally drops preceeding zeroes) - even though the
format is correct in the destination cell once the UserForm is closed.
What I'm trying to avoid is confusion in the minds of some of the
folks who will be using this workbook...not all of them are especially
bright nor computer-literate. TIA.

tm





All times are GMT +1. The time now is 07:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com