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:

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
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.
 
Upvote 0
The problem is that in all these unlocked cells the user enters data and in some of the locked cells there are formulas.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,561
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top