• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

I want to unprotect sheet

Abhijeet

Active Member
Hi
I have code to Unprotect excel sheet but I want when I run this macro then open which excel I want to unprotect.Because this code which sheet is protect that sheet run this code so please tell me

Sub Passwordunlock()

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
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

ActiveSheet.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


End Sub
 
I have code to Unprotect excel sheet but I want when I run this macro then open which excel I want to unprotect.Because this code which sheet is protect that sheet run this code so please tell me
...
ActiveSheet.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)
Hi, Abhijeet!

That code is trying to unprotect the sheet that's actually active, i.e., ActiveSheet (bold is mine). So it is intended to be used over the selected sheet, and it doesn't apply to any other worksheets, so -despite of what you want the code to do- the procedure should be like this:
a) Place the code in a standard module or in a worksheet class module.
b) Select as active sheet the worksheet that you want to unprotect.
c) Run the code.

Repeat a), b) & c) for all the worksheets that you want to unprotect.

Regards!

PS: Assuming that the code is a shortened and working version of the usually found code at McGimpsey & Associates, which I haven't controlled and I won't control since it seems to be very short regarding the original at this link:
http://www.mcgimpsey.com/excel/removepwords.html
... but as you said "I have code to Unprotect excel sheet", I trust you.
 
I have protected sheet but I can not open VBA in that file so I want macro I can open that file & unprotect the sheets from that file.Please give me macro
 
Hi, Abhijeet!

Have you read carefully the 1st sentence in the link that I posted? No, of course, as usual you haven't, so here's the delivery:
"Note: For a discussion of File or VBA Project password protection, see here."

Now you should have realized that the original procedure (and I insist on making the difference between your posted code that you say "it works" and the original code at the posted link, which a lot of people will say that "it really works -if used for what's intended for, i.e. not for VBA passwords-), only works for 1 of the 5 types of password that Excel has:
- open file (doesn't work)
- write -not read only- (doesn't work)
- VBA project (doesn't work)
- Workbook protection (doesn't work)
- "orksheet protection (works)

Anticipating your next question, no, I don't know any other procedure for VBA. Just click on the "here" word in the original article and find out if there's something that might help you.

Regards!

PS: "Please give me macro". It's enough for me, sorry if I'm not of further help, I can't emulate Job at all.
 
Back
Top