Solved

Trap Protect Message

Posted on 2013-01-23
2
185 Views
Last Modified: 2013-02-07
With Excel 2007, I use vba that is triggered by a button on the worksheet to copy the last row and past it into the row just below it.   I want to force the user to use the button to add a new row because of all the data validation.  The worksheet is protected except for rows that they've entered data in and the new row.  

If they try to start typing in a new row without using the button they get a message to use the button followed by the standard protect message prompting for a password.  Can I get rid of that standard message or change it?  

I know I could just past a lot of blank rows that would have the validation but I never know what the user will do and they might remove the validation so I prefer to use the button.  Or is there another approach I could consider?

--Caren
0
Comment
Question by:CarenC
  • 2
2 Comments
 
LVL 26

Accepted Solution

by:
redmondb earned 500 total points
ID: 38812787
Hi, Caren.

Please see the attached for a couple of options...

(1) Sheet 1
Please see the code below. Only the green cells are not locked. If the user tries to make a selection that includes a locked cell then a message  is displayed and cell A1 is selected. (If all of the attempted selection are locked the message is "Locked", otherwise it's "Mixed".)

It's by no means bullet-proof and is more annoying than the Excel messages.

(1) Sheet 2
Again, green cells are unlocked. The sheet simply uses the standard Excel Sheet Protection, with only "Select unlocked cells" enabled. If the user wants to insert new rows then they'll have to use your button.

Regards,
Brian.
[embed=file 630179]Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim xLocked  As Variant

xLocked = Target.Locked

If xLocked = False Then Exit Sub

If IsNull(xLocked) Then
    MsgBox ("Mixed")
Else
    MsgBox ("Locked")
End If

Application.EnableEvents = False
    Me.Range("A1").Select
Application.EnableEvents = True

End Sub

Open in new window

Locked-Test.xls
0
 
LVL 26

Expert Comment

by:redmondb
ID: 38865477
Thanks, Caren. Which option did you use?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question