Excel VBA - Auto enable or disable command button on userform

Поделиться
HTML-код
  • Опубликовано: 3 мар 2019
  • How to enable or disable a command button on a UserForm when certain conditions are met? This video shows a step by step tutorial from creation of a UserForm (before 2:35) to discussion on enabling or disabling a command button (after 2:35).
    Useful code:
    UserForm1.Controls("TextBox" & i).Value = ""
    UserForm1.CommandButton1.Enabled = True
    Facebook public group for Excel and VBA discussion 👉 / 486402069483674
    Welcome to join 🤗

Комментарии • 18

  • @georgematsos4416
    @georgematsos4416 2 года назад +2

    Is there a way the button to be disabled and when all fields are complete to enable it ?
    No mouse hover code.
    I want to create a big form with many fields is there an option to test all fields ?
    Thanks.

    • @ahsingtv
      @ahsingtv  2 года назад

      Hi. I have checked to run using different procedures that available. Unfortunately, I couldn't find one that best satisfies your need.
      May I know is it because you have discontinuous number of text boxes where you can't run using "For i = 1 to xx"?
      If that's the case, you may try creating a dummy and run using this dummy to check all text boxes.
      For example:
      Dim a As Control
      For Each a In UserForm1.Controls
      If TypeName(a) = "TextBox" Then
      If a.Value = "" Then
      UserForm1.CommandButton1.Enabled = False
      End If
      End If
      Next
      This code will check all text boxes without referring to their numberings.
      Hope it helps. Thanks for watching and have a nice day.

    • @georgematsos4416
      @georgematsos4416 2 года назад

      @@ahsingtv Thanks for the help i really appreciate it.

    • @ahsingtv
      @ahsingtv  2 года назад

      My pleasure. Have a nice day :)

  • @tengseyha6668
    @tengseyha6668 2 года назад

    Hi brother, I have follow your instruction, code is working but when I renamed all TextBox (like: TextBox1, TextBox2... etc) to txtName, txtAddress. After that code isn't working and show error: could not find the specified object. what's wrong and how to fix brother?

    • @ahsingtv
      @ahsingtv  2 года назад

      Hi Seyha. Did you change the names of those textboxes at the properties window?

    • @tengseyha6668
      @tengseyha6668 2 года назад

      @@ahsingtv yes bro.

    • @ahsingtv
      @ahsingtv  2 года назад

      @@tengseyha6668 do you mind to send your file to me at ahsing.math.excel@gmail.com? I suspect there might be a define error.

  • @dynamic_duo157
    @dynamic_duo157 2 года назад

    How to get" list index name" on combobox vba excel
    Example: Select Country

    • @ahsingtv
      @ahsingtv  2 года назад

      Hi, achyut. Really sorry for this late reply.
      I have record two videos, hope at least one of them could help.
      Combo Box on UserForm 👉 ruclips.net/video/wvCH3CNZKks/видео.html
      Combo Box on Worksheet 👉 ruclips.net/video/asqUSmZugNg/видео.html
      Have a nice day.

  • @samnangsuonsokunth8719
    @samnangsuonsokunth8719 9 месяцев назад

    sir please show transfer data too?

    • @samnangsuonsokunth8719
      @samnangsuonsokunth8719 9 месяцев назад

      please show me transfer data code too? thank you

    • @ahsingtv
      @ahsingtv  9 месяцев назад

      Hi. May I know what kind of data transfer are you referring? UserForm to Sheet? UserForm to UserForm or else?

    • @samnangsuonsokunth8719
      @samnangsuonsokunth8719 9 месяцев назад

      to sheet database sir

    • @samnangsuonsokunth8719
      @samnangsuonsokunth8719 9 месяцев назад

      referren with this video