Go to specific range with locked cells

girapas

Board Regular
Joined
Apr 20, 2004
Messages
150
In Sheet1 I have 4 buttons to call the corresponding sub (say page1, page2, page3, page4) that goes to a specific range in Sheet2 (say rng1, rng2, rng3, rng4). I use the following code:

Sub page1()
Set rng1 = ActiveWorkbook.Worksheets("Sheet2").Range("B1:J20")
Application.Goto rng1, True
End Sub

Sub page2()
Set rng2 = ActiveWorkbook.Worksheets("Sheet2").Range("L1:T20")
Application.Goto rng2, True
End Sub

and so on.

That works fine, expect if I want to prevent the user to select some cells in Sheet2, that must be both protected and not selected, adding that in subs page1, page2, page3, page4:

ActiveSheet.EnableSelection = xlUnlockedCells
ActiveSheet.Protect Contents:=True

Is there any way to override it?
Thanks in advance...
 
Last edited:

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
7,497
Office Version
2016
Platform
Windows
In Sheet1 I have 4 buttons to call the corresponding sub (say page1, page2, page3, page4) that goes to a specific range in Sheet2 (say rng1, rng2, rng3, rng4). I use the following code:

Sub page1()
Set rng1 = ActiveWorkbook.Worksheets("Sheet2").Range("B1:J20")
Application.Goto rng1, True
End Sub

Sub page2()
Set rng2 = ActiveWorkbook.Worksheets("Sheet2").Range("L1:T20")
Application.Goto rng2, True
End Sub

and so on.

That works fine, expect if I want to prevent the user to select some cells in Sheet2, that must be both protected and not selected, adding that in subs page1, page2, page3, page4:

ActiveSheet.EnableSelection = xlUnlockedCells
ActiveSheet.Protect Contents:=True

Is there any way to override it?
Thanks in advance...
You could always unprotect the worksheet at the start of the Sub and protect it back at the end of it.
 

girapas

Board Regular
Joined
Apr 20, 2004
Messages
150
The problem is that in all these unlocked cells the user enters data and in some of the locked cells there are formulas.
 

Forum statistics

Threads
1,082,548
Messages
5,366,227
Members
400,880
Latest member
dwb

Some videos you may like

This Week's Hot Topics

Top