ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   A Follow up to Userform Formating (https://www.excelbanter.com/excel-discussion-misc-queries/83277-follow-up-userform-formating.html)

Jeff

A Follow up to Userform Formating
 
Hi,

Thanks for your help in the last post. There is one problem I am having
though. I need to input numbers into an input box in the userform, and I
would like the numbers formatted. I have the input box linked to a cell in
the workspace. But using the code

TextBoxPayments.value = format(Sheets("Input").Range("D8").Value, "$#,##0")
or
TextBoxPayments.value = Sheets("Input").Range("D8").text

Does not allow me to change the value in the input box, it sets the input
box to the value in D8. Is there any way around this so I can input values
that are formatted?

Thanks for your help

Dave Peterson

A Follow up to Userform Formating
 
I'd drop the linked cell and have the code change the value in the cell:

Option Explicit
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
With Me.TextBox1
If IsNumeric(.Value) Then
Worksheets("Input").Range("D8").Value = .Value
.Value = Format(.Value, "$#,##0")
End If
End With
End Sub



Jeff wrote:

Hi,

Thanks for your help in the last post. There is one problem I am having
though. I need to input numbers into an input box in the userform, and I
would like the numbers formatted. I have the input box linked to a cell in
the workspace. But using the code

TextBoxPayments.value = format(Sheets("Input").Range("D8").Value, "$#,##0")
or
TextBoxPayments.value = Sheets("Input").Range("D8").text

Does not allow me to change the value in the input box, it sets the input
box to the value in D8. Is there any way around this so I can input values
that are formatted?

Thanks for your help


--

Dave Peterson


All times are GMT +1. The time now is 11:17 PM.

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