You can reference the codename and macro using:
Private Sub Workbook_Open()
Call Sheet1.Worksheet_Change(Range("V1"))
Call Sheet2.Worksheet_Change(Range("V1"))
End Sub
It is less clean doing it this way, but it will work. You do need to pass the correct range (Range("V1")) to trigger the conditional change. I would still recommend using the worksheet_change rather than the worksheet_selectionchange event.
It looks like I had mucked up my earlier code anyway, it would look more like this:
public sub Workbook_Open()
Call RefreshPageLock(worksheets("Sheet1").Range("V1"))
end sub
public sub RefreshPageLock(byval Target as Excel.Range)
Dim NewRange As String, _
TopRow As Long
With target.parent
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 = .Name
End If
End With
exit_routine:
Application.EnableEvents = True
Application.ScreenUpdating = True
end sub
private sub Worksheet_Change(byval Target as Excel.Range)
if not intersect(Target, Range("V1:V3")) is nothing then
call refreshpagelock(target)
endif
end sub
Bookmarks