Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Trap Protect Message

Posted on 2013-01-23
2
Medium Priority
?
201 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 2000 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

722 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