'Combine three procedures in VBA
Good afternoon,
I am trying to combine the three following VBA segments without any luck. Searching hasn't done me much good. Would appreciate any assistance.
Sub UnProtectSheetWithPassword()
Sheets("Sheet2").Unprotect Password:="myPassword
End Sub"
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("O3").Address Then
Range("B8:Q507").CurrentRegion.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("O2:O3")
End If
End Sub
Sub ProtectSheetWithPassword()
Sheets("Sheet2").Protect Password:="myPassword"
End Sub
Solution 1:[1]
Maybe this is what you want ?
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("O3").Address Then
Sheets("Sheet2").Unprotect Password:="myPassword"
Range("B8:Q507").CurrentRegion.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("O2:O3")
Sheets("Sheet2").Protect Password:="myPassword"
End If
End Sub
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Spectral Instance |
