Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Prevent any cells being selected

Posted on 2014-02-05
2
Medium Priority
?
236 Views
Last Modified: 2014-02-09
Hi

I noticed in vba within the sheets properties is a function which prevents any cells being selected if the sheet is locked, how can I enable this with a vba command?
0
Comment
Question by:DemonForce
2 Comments
 
LVL 81

Accepted Solution

by:
byundt earned 2000 total points
ID: 39837898
The setting in the Properties for the worksheet doesn't accomplish anything until the worksheet is protected, as you have discovered.

In VBA, you would want to protect the worksheet first, then make the setting to prevent cell selection.
Sub NoSelection()
With Worksheets("Sheet1")
    .Protect
    .EnableSelection = xlNoSelection
End With
End Sub

Open in new window

0
 
LVL 31

Expert Comment

by:gowflow
ID: 39838274
@byundt thumbs up !!! nice one I didn't know about it very handy.
gowflow
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

916 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