edwardzbrown
New Member
- Joined
- Jun 12, 2017
- Messages
- 20
I've created a button that saves as the workbook with a custom name with the word "report". It' Puts the words "Locked Report" on every sheet. Problem is, it's not locked. Part of my functionality of this workbook is I have control buttons create customized entry fields. Some cells are protected and others are not so my sheet is user proof and also able to insert new entry ranges. Well, when I create the "generate report" (save as) button, it locks the workbook (ActiveWorkbook.Protect ("password"), True, True) but locking the workbook doesn't even lock the same way lock sheet does. Furthermore, locking the sheet doesn't lock the cells that are unprotected. But locking each sheet gets me close to what I want.
Should I make a code to protect every sheet individually? what does protect workbook do? It doesn't seem to protect anything. That's my first and second question.
I'm thinking if I can't lock unprotected cells, It's good enough to protect the worksheets because that prevents cell selection (whether protected or not) which is enough. But the buttons that create custom ranges are still functioning. Could I create a macro to clear out my code in each of the modules I created? This "report" is just a locked down freeze frame of where the document is at. The original is preserved with all the macros. I'm thinking that a clear/delete Module 1-5 would work, and keep the save-as button in module 6.
I really think that deleting select modules is all I need to make this Generate Report button work for me. Is that possible?
Should I make a code to protect every sheet individually? what does protect workbook do? It doesn't seem to protect anything. That's my first and second question.
I'm thinking if I can't lock unprotected cells, It's good enough to protect the worksheets because that prevents cell selection (whether protected or not) which is enough. But the buttons that create custom ranges are still functioning. Could I create a macro to clear out my code in each of the modules I created? This "report" is just a locked down freeze frame of where the document is at. The original is preserved with all the macros. I'm thinking that a clear/delete Module 1-5 would work, and keep the save-as button in module 6.
HTML:
Sub Button9_Click()'Save Report Button on Dashboard'need to add a way to lock the entire report and add LOCKED text to bodyActiveWorkbook.RefreshAll 'so refreshing
'unlock sheetActiveSheet.Unprotect ("password")
Sheets("Dashboard").Select Range("K9").Select ActiveCell.FormulaR1C1 = "Locked Report"
Sheets("Revision History").Select Range("C4").Select ActiveCell.FormulaR1C1 = "Locked Report"
Sheets("A10").Select Range("E5").Select ActiveCell.FormulaR1C1 = "Locked Report"
Sheets("A20").Select Range("E5").Select ActiveCell.FormulaR1C1 = "Locked Report" Sheets("B10").Select Range("E5").Select ActiveCell.FormulaR1C1 = "Locked Report" 'etc. There are more sheets, I deleted out of this example because you get the idea.
'save as code Dim part1 As String Dim part2 As String part1 = Month(['Revision History'!A2]) & "-" & Day(['Revision History'!A2]) & "-" & Year(['Revision History'!A2]) part2 = Range("Dashboard!A5").Value ActiveWorkbook.SaveAs Filename:=relativePath & part1 & " " & part2 & " Report.xlsm", FileFormat:= _ xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
MsgBox "This is your generated report. Close out and open your A-SCR2 document to continue working", vbInformation, "A-SCR2"
'lock sheetActiveWorkbook.Protect ("password"), True, TrueEnd Sub
I really think that deleting select modules is all I need to make this Generate Report button work for me. Is that possible?