Solved

Trap Protect Message

Posted on 2013-01-23
2
159 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
Comment Utility
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
Comment Utility
Thanks, Caren. Which option did you use?
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
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…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now