Results 1 to 4 of 4

How to enable textbox when a specific item in combobox is selected?

Threaded View

Wilheim How to enable textbox when a... 05-20-2021, 01:39 AM
torachan Re: How to enable textbox... 05-20-2021, 02:22 AM
Wilheim Re: How to enable textbox... 05-20-2021, 02:34 AM
torachan Re: How to enable textbox... 05-20-2021, 02:52 AM
  1. #1
    Registered User
    Join Date
    04-12-2021
    Location
    Singapore
    MS-Off Ver
    Office 365
    Posts
    8

    Question How to enable textbox when a specific item in combobox is selected?

    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]
    Last edited by Wilheim; 05-20-2021 at 04:39 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 01-18-2020, 12:44 AM
  2. [SOLVED] Match Combobox with textbox then enable password: HOW TO?
    By poizones in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 11-08-2018, 03:58 AM
  3. [SOLVED] enable/disable combobox based on textbox entry
    By bqheng in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-05-2017, 11:53 AM
  4. Combobox enable textbox
    By jpernice in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-24-2015, 09:16 PM
  5. selecting an item in combobox, the item does not get selected
    By AVM in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-14-2014, 05:14 AM
  6. Replies: 3
    Last Post: 04-02-2013, 06:02 PM
  7. Combobox: How to determine the location of the selected item if combobox has rowsource
    By ahsanzafar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-11-2012, 03:24 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1