Highlighting cells after protecting sheet

WarriorJ

New Member
Joined
Jan 6, 2014
Messages
9
I have created some buttons in my excel sheet to highlight cells when clicked. However, I also want to protect the document so that only certain cells can be modified. When I protect the document the buttons no longer work even though the specified cells aren't locked. I'm sure it is just some simple setting that I don't know about.

Here is the code for the highlighting button:

Sub highlightgreen()
'
' highlightgreen Macro
' highlights the current cell in green to denote passage through x-ray
'
' Keyboard Shortcut: Ctrl+g
'
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 5296274
.TintAndShade = 0
.PatternTintAndShade = 0
End With

Selection.Offset(1, 0).Select
End Sub
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Alright,

I'm a dummy. I just corrected by entering code to unprotect and re-protect before and after the highlighting function. May not be the "proper" way to do it but it seems to work. Still up for learning if anyone has a better solution.

Thanks!
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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