Hide command button on worksheet depending on worksheet cell value

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,832
Office Version
  1. 2007
Platform
  1. Windows
I normally work with userforms so this is different for me.

On my worksheet in cell E3 will either be (1) or (2) brackets are also shown in cell.
Depending which value is in the cell depends which command button i would like to be shown / hidden on the worksheet.

The following code hides command button fine but now i dont see either of them.
I have put the code in the change event.
Im expecting the command buttons to toggle etc but not sure what ive done or where to go from here

I also dont think change event is correct as i need the code to monitor it all the time


Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub

On Error Resume Next

If Not Intersect(Target, Range("A1:A38" & "," & "N4:S32")) Is Nothing Then
Application.EnableEvents = False
Target = UCase(Target)
Application.EnableEvents = True

End If
On Error GoTo 0

If Range("E3") = (1) Then
SecondMonthsSheet.Visible = False
End If

If Range("E3") = (2) Then
TransferButton.Visible = False
End If

End Sub
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
@ipbr21054
I'm assuming that (1) and (2) are in cell formatted as text ?
If so, does the below help?

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub

On Error Resume Next

If Not Intersect(Target, Range("A1:A38" & "," & "N4:S32")) Is Nothing Then
Application.EnableEvents = False
Target = UCase(Target)
Application.EnableEvents = True

End If
On Error GoTo 0


SecondMonthsSheet.Visible = Range("E3") = "(1)"


TansferButton.Visible = Range("E3") = "(2)"


End Sub
 
Upvote 0

Forum statistics

Threads
1,224,737
Messages
6,180,653
Members
452,992
Latest member
TokugawaIesuma

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top