tlc53
Active Member
- Joined
- Jul 26, 2018
- Messages
- 399
Hi,
I'm trying to hide a command button if cell D8 does not equal 1, 2, 3 or 4. D8 is a dropdown, so changes manually. I have the following code below (which may or may not work) but I'm having difficulty including it with my other code (also below) as I keep getting errors. Can someone help me piece the two together please?
I'm trying to hide a command button if cell D8 does not equal 1, 2, 3 or 4. D8 is a dropdown, so changes manually. I have the following code below (which may or may not work) but I'm having difficulty including it with my other code (also below) as I keep getting errors. Can someone help me piece the two together please?
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Range(D8).Value <> "1,2,3,4" Then
Me.CommandButton1.Visible = True
Else
Me.CommandButton1.Visible = False
End If
Application.ScreenUpdating = True
End Sub
Code:
Private Sub CommandButton1_Click()
PDFRentalStmtNo1
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("No._Rentals")) Is Nothing Then
If Target.Cells.CountLarge > 1 Then Exit Sub
Select Case Target.Value
Case "Please Select"
Range("15:18,42:110,42:260").EntireRow.Hidden = True
Case 1
Range("15:18,42:110,42:260").EntireRow.Hidden = False
Range("16:18,60:110,119:125,132:148,150:260").EntireRow.Hidden = True
Case 2
Range("15:18,42:110,42:260").EntireRow.Hidden = False
Range("17:18,77:110,119:125,132:148,156:162,169:185,187:260").EntireRow.Hidden = True
Case 3
Range("15:18,42:110,42:260").EntireRow.Hidden = False
Range("18:18,94:110,119:125,132:148,156:162,169:185,193:199,206:222,224:260").EntireRow.Hidden = True
Case 4
Range("15:18,42:110,42:260").EntireRow.Hidden = False
Range("119:125,132:148,156:162,169:185,193:199,206:222,230:236,243:259").EntireRow.Hidden = True
End Select
End If
Dim rng As Range
Set rng = Intersect(Target, [B118:B125,B131:B148,B155:B162,B168:B185,B192:B199,B205:B222,B229:B236,B242:B259])
If Not rng Is Nothing Then rng(2, 1).EntireRow.Hidden = False
End Sub
Sub Rental_Stmt_No1()
With Sheet80
.Asset_Hide_Prop_1
.Asset_Hide_Chat_1
End With
PDFRentalStmtNo1
End Sub
Sub Rental_Stmt_No2()
With Sheet81
.Asset_Hide_Prop_2
.Asset_Hide_Chat_2
End With
PDFRentalStmtNo2
End Sub
Sub Rental_Stmt_No3()
With Sheet82
.Asset_Hide_Prop_3
.Asset_Hide_Chat_3
End With
PDFRentalStmtNo3
End Sub
Sub Rental_Stmt_No4()
With Sheet83
.Asset_Hide_Prop_4
.Asset_Hide_Chat_4
End With
PDFRentalStmtNo4
End Sub