Hide/Unhide CommandButton by cell criteria

  • Thread starter Thread starter cru
  • Start date Start date
C

cru

Can i have more than two range under SelectionChage?

I currently have this code but I got the first two range to work but the
third range does not work:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("D18").Value = "YES" Then
Me.CommandButton13.Visible = True
Else
Me.CommandButton13.Visible = False
End If
If Range("D19").Value = "YES" Then
Me.CommandButton28.Visible = True
Else
Me.CommandButton28.Visible = False
End If
If Range("D21").Value = "YES" Then
Me.CommandButton29.Visible = True
Else
Me.CommandButton29.Visible = False
End If
End Sub
 
Hi,

That should work perfectly but if it doesn't consider the following

the YES in the cells must be uppercase
Ensure you have the correct commandbutton number in your code
The use of ME isn't necessary but shouldn't cause a problem

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top