chrono2483
Board Regular
- Joined
- Aug 23, 2014
- Messages
- 164
- Office Version
- 2016
Hello Everyone,
Did some additional research and got some help on a code to protect my worksheet, as well as autosave, however I seem to keep getting errors.
I have a worksheet/tool called "Save Tool", with multiple tabs. What I want is the code to:
1) Unprotect all tabs
2) Perform the tasks of the code, which includes copy/pasting from one tab to the next
3) Re-protect all tabs
4) Save the Tool based on the "Worksheet Name" & "-" & "date in Sheet 1, Cell A3" (ex. Save Tool - 1/15/16)
5) Save the file using the file name created in #4 in a specific destination on the users desktop (C:\Users\John Doe\Desktop\)
The code I have been playing with is:
Can someone help with the code, or maybe point in the right direction?
Thank you!
Did some additional research and got some help on a code to protect my worksheet, as well as autosave, however I seem to keep getting errors.
I have a worksheet/tool called "Save Tool", with multiple tabs. What I want is the code to:
1) Unprotect all tabs
2) Perform the tasks of the code, which includes copy/pasting from one tab to the next
3) Re-protect all tabs
4) Save the Tool based on the "Worksheet Name" & "-" & "date in Sheet 1, Cell A3" (ex. Save Tool - 1/15/16)
5) Save the file using the file name created in #4 in a specific destination on the users desktop (C:\Users\John Doe\Desktop\)
The code I have been playing with is:
Code:
Sub Macro2()
Dim ws As Worksheet
For Each ws In Worksheets
ws.Activate
ws.Unprotect "password"
Columns("B:B").ColumnWidth = 15.71
Columns("C:C").ColumnWidth = 16
Sheets("Sheet2").Select
Columns("B:B").ColumnWidth = 11
Sheets("Sheet1").Select
Range("A1").Select
ws.Protect "password"
Next ws
Dim FName As String
ActiveSheet.Copy
With ActiveSheet.UsedRange
.Copy
.PasteSpecial xlValues
.PasteSpecial xlFormats
End With
Application.CutCopyMode = False
FName = "C:\Users\John Doe\Desktop\" & Format(Range("A3"), "mmm-d-yyyy") & ".xlsm"
ActiveWorkbook.SaveAs Filename:=FName, _
FileFormat:=xlOpenXMLWorkbookMacroEnabled
End Sub
Can someone help with the code, or maybe point in the right direction?
Thank you!