Hi All I have this code below,
I'm trying to figure out how i can copy protected sheets and unprotect together with copying a specific range and pasting it as value only.
Hoping for a quick response. Thank you! ?
I'm trying to figure out how i can copy protected sheets and unprotect together with copying a specific range and pasting it as value only.
Hoping for a quick response. Thank you! ?
Code:
Sub CopySheets() Application.ScreenUpdating = False
Dim MyFolder As String, MyFile As String, srcWB As Workbook, desWB As Workbook
Set desWB = ThisWorkbook
On Error Resume Next
ActiveWorkbook.Unprotect Password:="sky1212"
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Please select a folder"
.Show
.AllowMultiSelect = False
If .SelectedItems.Count = 0 Then
MsgBox "You did not select a folder."
Exit Sub
End If
MyFolder = .SelectedItems(1) & "\"
End With
MyFile = Dir(MyFolder)
Do While MyFile <> ""
Set srcWB = Workbooks.Open(Filename:=MyFolder & "\" & MyFile)
With srcWB
.Sheets(1).Copy desWB.Sheets(desWB.Sheets.Count)
With ActiveSheet.UsedRange
.Cells.Validation.Delete
.Cells.Value = .Cells.Value
End With
.Close False
End With
MyFile = Dir
Loop
Application.ScreenUpdating = True
Worksheets("Sheet1").Visible = xlSheetHidden
End Sub