HI All,
I have a macro here that is conditionally locking cells. I have the cells being conditionally locked based on V1, V2, and V3 as you can see below. If we say that this code is on sheet2, Then V1, V2, and V3 are coming from Sheet1, just in the form of =Sheet1$A$1.... On sheet1 i am asking the user a series of questions, and what they answer will conditionally lock this sheet. This code works great at conditionally locking the sheet. I am only having one problem and a major one at that. What happens is that for some reason the sheet must not be refreshing upon opening and therefore it will not unlock any of the cells. All the cells are locked and i have to unprotect the sheet manually then click on one of the cells and the sheet will refresh and conditionally lock based on the criteria that the user has given. I am looking for some sort of code that i can possibly put in the front of my code to refresh the page upon opening. I feel like if the page were to refresh that this would clear my problem and the conditional lock will then work perfectly upon opening the sheet. I am pretty new to VBA, so if you could post your code and where excactly to put it in my workbook/worksheet. Thank you to all for the help.
![]()
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim NewRange As String, _ TopRow As Long With ActiveSheet If .Range("V1").Value <> "" And .Range("V2").Value <> "" Then TopRow = .Range("V3").Value / 3 NewRange = .Range(.Cells(22 - TopRow, "B"), .Cells(22 - TopRow, "U")).Address(0, 0) & ":B22" .Unprotect "password" .Cells.Locked = True .Range(NewRange).Locked = False .Protect "password" .EnableSelection = xlUnlockedCells .Protect EditMode = ActiveSheet.Name End If End With exit_routine: Application.EnableEvents = True Application.ScreenUpdating = True End Sub











LinkBack URL
About LinkBacks
Register To Reply
Bookmarks