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 🤗
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.
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.
@@ahsingtv Thanks for the help i really appreciate it.
My pleasure. Have a nice day :)
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?
Hi Seyha. Did you change the names of those textboxes at the properties window?
@@ahsingtv yes bro.
@@tengseyha6668 do you mind to send your file to me at ahsing.math.excel@gmail.com? I suspect there might be a define error.
How to get" list index name" on combobox vba excel
Example: Select Country
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.
sir please show transfer data too?
please show me transfer data code too? thank you
Hi. May I know what kind of data transfer are you referring? UserForm to Sheet? UserForm to UserForm or else?
to sheet database sir
referren with this video