I created a userform, which contains a combobox (Process A, B, C, and D) and two textboxes; the name of the combobox is Process whereas the names of the textboxes are P_Ini and P_Fi
I would like the textboxes to be enabled (they are disabled by default) when Process A is selected. When I tested the codes, the textboxes remained disabled. Not sure what went wrong here, so I would appreciate if anyone could advise on this.
[code]
Sub Process_Change()
'Textboxes are greyed out by default
If Process = "Process A" Then
P_Ini.Enabled = True
P_Fi.Enabled = True
P_Ini.BackColor = &H80000005 'colour code for white
P_Fi.BackColor = &H80000005
Else
P_Ini.Enabled = False
P_Fi.Enabled = False
End If
'PURPOSE: Prevent user from entering non-numerical values in userform textbox
'Allow for negative numbers
If Not IsNumeric(P_Ini.Value) And P_Ini <> "-" And P_Ini <> "" Then
P_Ini = Left(P_Ini, Len(P_Ini) - 1)
MsgBox "Only numbers allowed"
Cancel = True
P_Ini.Value = ""
End If
If Not IsNumeric(P_Fi.Value) And P_Fi <> "-" And P_Fi <> "" Then
P_Fi = Left(P_Fi, Len(P_Fi) - 1)
MsgBox "Only numbers allowed"
Cancel = True
P_Fi.Value = ""
End If
End Sub
[\code]
Bookmarks