Hide/Unhide CommandButton by cell criteria

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
 
M

Mike H

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
 
Top