Protection issuse wihtlocked columns

lemiller521

New Member
Joined
Aug 28, 2006
Messages
4
I have written some simple code (with help from this group) that highlights the selected row. The code is:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Row = 1 Or Target.Rows.Count > 1 Then Exit Sub
Cells.Interior.ColorIndex = xlColorIndexNone
ActiveCell.EntireRow.Interior.ColorIndex = 36
Range("aa1") = ActiveCell.Row
End Sub


However, when I lock certain columns and protect the worksheet, the ColorIndex property is not accessible. This results in an error message.

Is there some way around this? Perhaps some combination of user permissions when I protect the worksheet?

Thanks.

Lou
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Not so complex as permissions. Just add this. You just need to unlock, make the change, then lock the sheet again.

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
activesheet.unprotect "Password"
If Target.Row = 1 Or Target.Rows.Count > 1 Then Exit Sub
Cells.Interior.ColorIndex = xlColorIndexNone
ActiveCell.EntireRow.Interior.ColorIndex = 36
Range("aa1") = ActiveCell.Row
Activesheet.protect "Password"
End Sub

HTH
Cal
 
Upvote 0

Forum statistics

Threads
1,224,269
Messages
6,177,563
Members
452,784
Latest member
talippo

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