Solved

Trap Protect Message

Posted on 2013-01-23
2
191 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
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…

756 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