B
bforster1
I have written the following code to ensure no formula error occurs i
the enduser enters something other than a numeric (alpha, ..., etc.)
want the MsgBox to fire only if a nonnumeric is entered. However, wit
the code below each time I hit tab or enter the MsgBox fires. Th
TextBox can either be populated or blank when the enduser loads th
UserForm. If the enduser enters a numeric I want the cell to populat
accordingly and move to the next textbox in the tab order. If
nonnumeric is entered I want the Msg to fire and when the enduser hit
OK the corresponding textbox (TextBox40 in the case below) should clea
and the focus should remain on TextBox40.
Private Sub TextBox40_AfterUpdate()
If TextBox40 <> "" And Not IsNumeric(TextBox40) Then
MsgBox "Number Expected Here" & vbLf & "Please Try Again"
TextBox40.Text = ""
End If
Sheets("IncStmtAssump").Range("F7") = TextBox40.Value
If ComboBox6.Value = "% of Revenue" Then TextBox40.Text
Format(TextBox40.Text, "0.00%")
If ComboBox6.Value = "Input" Then TextBox40.Text
Format(TextBox40.Text, "$#,##0")
If ComboBox6.Value = "% Change from Previous Year" Then TextBox40.Tex
= Format(TextBox40.Text, "0.00%")
If ComboBox6.Value = "$ Change from Previous Year" Then TextBox40.Tex
= Format(TextBox40.Text, "$#,##0")
UserForm_Initialize
End Sub
Thanks
the enduser enters something other than a numeric (alpha, ..., etc.)
want the MsgBox to fire only if a nonnumeric is entered. However, wit
the code below each time I hit tab or enter the MsgBox fires. Th
TextBox can either be populated or blank when the enduser loads th
UserForm. If the enduser enters a numeric I want the cell to populat
accordingly and move to the next textbox in the tab order. If
nonnumeric is entered I want the Msg to fire and when the enduser hit
OK the corresponding textbox (TextBox40 in the case below) should clea
and the focus should remain on TextBox40.
Private Sub TextBox40_AfterUpdate()
If TextBox40 <> "" And Not IsNumeric(TextBox40) Then
MsgBox "Number Expected Here" & vbLf & "Please Try Again"
TextBox40.Text = ""
End If
Sheets("IncStmtAssump").Range("F7") = TextBox40.Value
If ComboBox6.Value = "% of Revenue" Then TextBox40.Text
Format(TextBox40.Text, "0.00%")
If ComboBox6.Value = "Input" Then TextBox40.Text
Format(TextBox40.Text, "$#,##0")
If ComboBox6.Value = "% Change from Previous Year" Then TextBox40.Tex
= Format(TextBox40.Text, "0.00%")
If ComboBox6.Value = "$ Change from Previous Year" Then TextBox40.Tex
= Format(TextBox40.Text, "$#,##0")
UserForm_Initialize
End Sub
Thanks