Hi
I have macro this work but i have 200 files & 5 sheets so this macro take to much time can u please tell me how to Run Fast this macro.
I have macro this work but i have 200 files & 5 sheets so this macro take to much time can u please tell me how to Run Fast this macro.
Code:
Sub unprotect()
Dim ws As Worksheet, strWB As Workbook
Dim myPath As String, sFile As String
Dim i As Integer, j As Integer, k As Integer
Dim l As Integer, m As Integer, n As Integer
Dim i1 As Integer, i2 As Integer, i3 As Integer
Dim i4 As Integer, i5 As Integer, i6 As Integer
Application.ScreenUpdating = False
myPath = Application.ThisWorkbook.Path & "\"
sFile = Dir(myPath & "*.xl??")
If sFile = "" Then
MsgBox "No CAF_File found!!!", vbCritical
Exit Sub
End If
Do While sFile <> ""
Set strWB = Workbooks.Open(myPath & sFile)
For Each ws In strWB.Worksheets
'ws.unprotect
On Error Resume Next
For i = 65 To 66: For j = 65 To 66: For k = 65 To 66
For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66
For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66
For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126
ws.unprotect Chr(i) & Chr(j) & Chr(k) & _
Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _
Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
Next: Next: Next: Next: Next: Next
Next: Next: Next: Next: Next: Next
Next
strWB.Close True
sFile = Dir
Loop
Set strWB = Nothing
Application.ScreenUpdating = True
End Sub
Attachments
Last edited by a moderator: