ColinCoady
New Member
- Joined
- Mar 21, 2019
- Messages
- 35
Hi All
I want to add another section of code that will make my commandButton1 visible or not based on all 5 cells having data. If all five have data then show button if not don't show button. The 5 cells are, A3, A4, A5, A6, A7.
I've got the code to do this for commandButton2 based on one cell having data or not - works great.
I want get CommandButton1 to work based on more than 1 cell having data. Need 5 cells to all have data before showing the button.
Also to test if I just copy the code starting at Application.ScreenUpdating... and change the CommandButton2 to CommandButton1 and change the Cells(4,2) to (3, 2) it does not work. CommandButton2 will still work though (visible or not).
What am I doing wrong?
I removed the test code for commandbutton1. Can you share how to get the commandButton1 to be visible or not?
The first 7 lines of code do something else for me and are working as they should.
I want to add another section of code that will make my commandButton1 visible or not based on all 5 cells having data. If all five have data then show button if not don't show button. The 5 cells are, A3, A4, A5, A6, A7.
I've got the code to do this for commandButton2 based on one cell having data or not - works great.
I want get CommandButton1 to work based on more than 1 cell having data. Need 5 cells to all have data before showing the button.
Also to test if I just copy the code starting at Application.ScreenUpdating... and change the CommandButton2 to CommandButton1 and change the Cells(4,2) to (3, 2) it does not work. CommandButton2 will still work though (visible or not).
What am I doing wrong?
I removed the test code for commandbutton1. Can you share how to get the commandButton1 to be visible or not?
The first 7 lines of code do something else for me and are working as they should.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("B5")) Is Nothing Then
If Range("B5") <> "" Then Range("B6:B11").ClearContents
End If
If Not Intersect(Target, Range("B6")) Is Nothing Then
If Range("B6") <> "" Then Range("B7:B11").ClearContents
End If
Application.ScreenUpdating = False
If Cells(4, 2).Value <> "" Then
Me.CommandButton2.Visible = False
Else
Me.CommandButton2.Visible = True
End If
Application.ScreenUpdating = True
End Sub