I have a question concerning locking multiple worksheets in Excel using the built in VB.
Based on whether a certain cell in Sheet 1 is a "Yes" or "No", I want other worksheets within the same book to become inactive. Lets say that if the cell in sheet 1 is "No" I want worksheets 2 and 3 to be locked, grayed out and basically inactive. Any ideas on how I woud do this using excels VBA? I am more experienced using VB.Net if it matters.
Many Thanks
28-02-2006 at 02:36 PM
|
~Bean~ Level: VB Guru Registered: 07-04-2003 Posts: 488
Re: Locking Worksheets in Excel using VBA
You can loop through the Worksheet collection and peform action to each sheet...
Dim wkSht As Worksheet
For Each wkSht In ThisWorkbook.Worksheets
With wkSht
If .Range("A1") = "Yes" Then
.Protect
Else
.Unprotect
End If
End With
Next
As for the "grayed out", Excel won't do this to signify enabled=False, you would need to set the Color of all the cells to gray, which would destroy any cell coloring you had in place...which is probably not what you want...
____________________________
Eggheads unite! You have nothing to lose but your yolks.