• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Enable button when cell (of a dropdown) is filled

NoobieXL

New Member
Hi all,

I hope you can help me with an issue for VBA. I would like enable a buttom only when, a cell (of a dropdown menu) is filled. I try this, but the button is still working when nothing is in the cell.

>>> use code - tags <<<
Code:
Public Sub dropdownbuttomchange1()

If Target.Address("$G$172").Value <> "" Then
   ButtomAssignmentSN.Enabled = True
  
Else
    ButtomAssignmentSN.Enabled = False
   
End If

End Sub
 
Last edited by a moderator:
I don't know what a dropdown menu is. Do you mean an ActiveX Combobox, Form Combobox, or a data validation cell?

Target is normally a range in worksheet events. I do not see where you defined it in your routine. Target.Address might be say "$A$1. As such, your code might be saying $A$1("$G$172").Value is not valid syntax. You might want to use something like:
Code:
If [G172] <> "" Then
It would be easier to help if attach a short example file. Click the Attach files button below a reply.
 
I don't know what a dropdown menu is. Do you mean an ActiveX Combobox, Form Combobox, or a data validation cell?

Target is normally a range in worksheet events. I do not see where you defined it in your routine. Target.Address might be say "$A$1. As such, your code might be saying $A$1("$G$172").Value is not valid syntax. You might want to use something like:
Code:
If [G172] <> "" Then
It would be easier to help if attach a short example file. Click the Attach files button below a reply.
Hi Kenneth. First thank you so much for trying to help me, really appreciated.
With dropdown menu I mean data validation cell indeed. I am not allowed to share the file as a whole. I have a code for the button itself, which is working, the button opens new rows for another data validation selection. But what is not working is "the button should only work when the validation field has been filled in/ selection has been made".

>>> as You have already noticed <<<
>>> use code - tags <<<
Code:
Public Sub ButtonAssignmentSN()

Rows("174:176").Select
If Selection.EntireRow.Hidden = True Then
Selection.EntireRow.Hidden = False
Else
Selection.EntireRow.Hidden = True

End If

End Sub

Public Sub dropdownbuttonchange1()

If [G172] <> "" Then
    ButtonAssignmentSN().Enabled = True
   
Else
    ButtonAssignmentSN().Enabled = False
   
  End If

End Sub
 
Last edited by a moderator:
NoobieXL
Your I am not allowed to share the file as a whole.
You have asked to upload a sample Excel file, which could show - what do You really mean? as well as would like to happen.
 
This is the sample of the file. As you can see I have multiple data validations. Every time you push the button the same validation appears (to add another assignment role). For now it is not fully working because of the sample.

It would be awesome if it can be that you only use the button when the former assignment role has been filled in.

Thanks!
 

Attachments

  • Sample.xlsx
    20 KB · Views: 8
NoobieXL
Are those ActiveX-components or what?
... for me, I cannot see any code anywhere as well as I won't use any ActiveX-components.
 
This are Excel Shapes (Insert --> shape). I dont know what ActiveX is to be honest. This shapes are connected to my macro;s.
 
NoobieXL
Which Your dropdowns are 'shapes'?
Your file have none code ( = marcos ) = none connection with any code and 'shape'.
... maybe Your macros are in Your original file - which is now linked to this file.
 
Please be more clear about your goal(s). For the file posted in #5, if I did what, what is expected? e.g.

1. IF B2 is changed
2. and IF B2 <> ""
3. Then enable: Rectangle: Rounded Corners 1
4. Else Disable: Rectangle: Rounded Corners 1
 
Back
Top