Customising Standard Popups

C

Colin Hayes

HI

This may be an impossible thing to do....

When I try to access a protected cell , I am given the standard Excel
popup saying that it is protected and that I can modify it by putting a
password in via the tools menu.

I do realise that the text in the popup can't be changed , but I was
wondering if the popup itself could be replaced with a message box or
validation popup whenever access to a protected cell is attempted?

Perhaps a small macro applying to all the protected parts for the sheets
could be triggered to replace the standard popup with a new one with a
customised message. (One that doesn't suggest users go digging around
trying to unprotect cells...)

Grateful for any help.
 
D

Dave Peterson

Maybe you could stop the users from selecting a locked cell on a protected
worksheet.

If all your users are using xl2002+, then there's an option in the
Tools|Protection|protect sheet dialog that allows you to specify if the user can
select unlocked cells.

If you're using xl2k or below, you'd need a macro:

Sub Auto_Open()
With Worksheets("Sheet99999")
.Unprotect Password:="hi"
.EnableSelection = xlUnlockedCells
.Protect Password:="hi", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End With
End Sub

In fact, in xl2k and below, this setting isn't remembered when you close the
workbook and reopened. Setting it in code was the only way to do this.
 
C

Colin Hayes

Hi Dave

OK thanks. I did think of that , but it doesn't help me because they
complain then that they can't select the cell...!

I do need a popup each time a protected cell is selected saying ' You
can't change this cell , and don't need to access it' , rather than
saying ' go and dig around in the options panel for a password..'

Not sure it's possible.

Thanks again.
 
R

Ron de Bruin

You can try this event in the sheet module

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Locked = True Then MsgBox "Sorry this cell is locked"
End Sub
 
C

Colin Hayes

Ron de Bruin said:
You can try this event in the sheet module

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Locked = True Then MsgBox "Sorry this cell is locked"
End Sub


Hi Ron

Yes , that would do it. Seems to be single click rather than double as
in the standard Excel popup.

Is there a way to apply it to the whole workbook at one go , or do I
need to put it in every worksheet separately , do you know?

Great stuff Ron - Thanks.
 
D

Dave Peterson

Remove any code that you added to any of the worksheets.

Put this behind the ThisWorkbook module.

Option Explicit
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)

If Sh.ProtectContents = True _
Or Sh.ProtectDrawingObjects = True _
Or Sh.ProtectScenarios = True Then
If Target.Cells(1).Locked = True Then
MsgBox "Sorry, the activecell cell is locked"
End If
End If

End Sub

===
Just my opinion--as a user, I would soon tire of this.
 
G

Gord Dibben

Colin

In Thisworkbook module, not in a sheet module.

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)
If Target.Locked = True Then MsgBox "Sorry this cell is locked"
End Sub


Gord Dibben MS Excel MVP
 
G

Gord Dibben

Colin

Be aware that this pop-up will occur even if the sheet does not have protection
enabled.

Setting the cells' format to locked but not protecting the sheet is sufficient
to trigger the pop-up when a locked-format cell is selected.


Gord
 
C

Colin Hayes

Hi Dave

OK Thanks for that. It will work well.

I take your point about it being tiresome after a while. Although I
suppose it's only really taking the place of the standard excel pop-up.

The only difference is that the standard one is double-click , whereas
this one is on simple selection. Could it be made double-click , so that
it only pops up if the user insists? That would make it much less
wearisome and it would operate at the same frequency as the standard
one. Don't know if that's possible.

Thanks for your help with this.
 
C

Colin Hayes

Gord Dibben said:
Colin

Be aware that this pop-up will occur even if the sheet does not have protection
enabled.

Setting the cells' format to locked but not protecting the sheet is sufficient
to trigger the pop-up when a locked-format cell is selected.


Gord

HI Gord

Yes , I see. I was hoping it would operate in the same way as the
standard popup , the difference being that I'd be able to control the
text in the popup.

Still , it would do the job and I'm grateful for your advice.


Best Wishes
 
D

Dave Peterson

The double click means that you're trying to edit the cell.

You can have your own pop up when you select the cell or after you update the
cell--but not right before you start editing the cell.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top