Solved

Excel - Locking a Sheet

Posted on 2016-07-26
6
65 Views
Last Modified: 2016-07-26
I have a Excel workbook with multiple sheets.   Each sheet equals a month.

Many cells on a sheet are locked and some are unlocked and editable.

Each sheet has some cells pulling dynamic info from cells on a master sheet.

I'd like a button that at the end of the month i can click to lock the particular sheet from further editing including further changes in dynamic cells (lock the current dynamic values and stop changing based on the master sheet).    

Thanks for any input.
0
Comment
Question by:tailoreddigital
[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
  • 4
  • 2
6 Comments
 
LVL 2

Accepted Solution

by:
Simulog earned 500 total points
ID: 41730248
Hi
Add a module, paste the following code into it and link a button on the worksheet to the macro
Option Explicit

Sub MakeStatic()
' This copies the used area and pastes values, turns on the locking of all used cells
' and locks the worksheet (without a password)
' Jörgen Möller 26Jul 2016
    With ActiveSheet.Range("A1", ActiveSheet.Range("A1").SpecialCells(xlCellTypeLastCell))
        .Copy
        .PasteSpecial Paste:=xlPasteValues
        .Locked = True
        .Range("A1").Select
    End With
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub

Open in new window


It should do the trick.

Good Luck
0
 
LVL 23

Author Comment

by:tailoreddigital
ID: 41730255
I'm testing this now.    

I know somebody is going to lock it and then realize that they need to change something.  

What code could i use to make it editable after MakeStatic?   It only would need to be editable, the dynamic cells don't need to revert to dynamic.
0
 
LVL 23

Author Comment

by:tailoreddigital
ID: 41730289
MakeStatic works.   I appreciate your expertise.    

To accomplish my need above, It looks like i'd just need to create another script that simply unprotects the active sheet.
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 23

Author Closing Comment

by:tailoreddigital
ID: 41730314
Thanks for the help
0
 
LVL 2

Expert Comment

by:Simulog
ID: 41730315
Yes and that is simple
Option Explicit

Sub UnProtSheet()
    ActiveSheet.Unprotect
End Sub

Open in new window

0
 
LVL 23

Author Comment

by:tailoreddigital
ID: 41730358
Thanks again, have a great day
0

Featured Post

SendBlaster Pro 4 - Bulk Email Sending Software

SendBlaster 4 Pro - Best Bulk Emailing Sending Software
Automatic Subscribe / Unsubscribe Processing
Great for Newsletters & Mass Mailings
Optional HTML & Text Composition
Integration with Google Features
Built in Spam Score Checking
Free Professional Templates - Feature Packed!

Question has a verified solution.

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

Suggested Solutions

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

739 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