[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Copy to a protected sheet

Posted on 2014-08-11
3
Medium Priority
?
170 Views
Last Modified: 2014-08-11
Hi,


My below sub copies data to a sheet that is now protected

The PW is "football"

My copy is now debugging, how can i code in the pw?

Thanks

Sub ClearChangeSummary()

'When the targets have been uploaded to CV, the admin will use this button to clear out uploaded amendments/additions




Application.ScreenUpdating = False
Sheets("Change Summary").Select

Dim Lastrow As Integer

Sheets("Change Summary").Range(Range("A2"), Range("L" & Rows.Count).End(xlUp)).Copy _
    Sheets("Log").Range("A" & Rows.Count).End(xlUp).Offset(1)


Lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row

Range("A2:L2" & Lastrow).ClearContents

Sheets("Admin").Select


Application.ScreenUpdating = True

End Sub

Open in new window

0
Comment
Question by:Seamus2626
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
Glenn Ray earned 2000 total points
ID: 40253419
Try this modified code:
Sub ClearChangeSummary()
'When the targets have been uploaded to CV, the admin will use this
'button to clear out uploaded amendments/additions

    Dim Lastrow As Integer
    
    Application.ScreenUpdating = False
    Sheets("Change Summary").Select
    ActiveSheet.Unprotect Password:="football"
    
    Range(Range("A2"), Range("L" & Rows.Count).End(xlUp)).Copy _
        Sheets("Log").Range("A" & Rows.Count).End(xlUp).Offset(1)
    
    Lastrow = Cells(Rows.Count, 1).End(xlUp).Row
    Range("A2:L2" & Lastrow).ClearContents
    ActiveSheet.Protect Password:="football"
    
    Sheets("Admin").Select
    Application.ScreenUpdating = True

End Sub

Open in new window


To be a little more hidden, you could create a string variable with the password and store it in another module.  

-Glenn
0
 

Author Closing Comment

by:Seamus2626
ID: 40253612
Thanks Glenn!
0
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40253664
You're Welcome! :-)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

830 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