macro on protected sheet

Homer J

New Member
Joined
Sep 20, 2003
Messages
23
I have a simple macro doing a text to columns function, but it won't run when the sheets are protected. Is this the way it's supposed to be? Is there a way I can change it? There's 2 worksheets using the same macro.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,456
Yes, that's the way it's supposed to be.
Seeing the code would be helpful, but without it, maybe this will still help.
You could either specify the sheets by name, or simply begin your code with:
Code:
ActiveSheet.Unprotect "Your password here"
and end the routine with:
Code:
ActiveSheet.Protect "Your password here"
You can leave out the "Your password here" if you aren't going to use one.

Hope it helps,
Dan

Edit: This will work if the macro is only performing on one sheet at a time. (the active sheet). If it's to work on both sheets at the same time you'll need to name them in the code.
 

Te4t0n

New Member
Joined
Jan 23, 2005
Messages
21
basicly yes, this is how it works, anyhow there is a way around it

i.e

you have this macro working on sheet1

so in the macro add:

sheet1.unprotect

macro code

sheet1.protect


now.. if you have a password, you will need to use sheet1.protect password = "mypassword"
and same for unprotect

hope this helps
 

m_woychick

New Member
Joined
Mar 22, 2004
Messages
33

ADVERTISEMENT

any idea on what' going on with this:

I password protect my worksheet.

I use the code above to uprotect, run macro, and protect again, including the password. Now when I manually go to unprotect the worksheet, it tells me the password is incorrect. I have done this with both with and without the Password = "password" -- that is

unprotect password = "password"
macro
protect password = "password"

and

unprotect "password"
macro
protect "password"
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,456
Those two things you've tried aren't going to make a difference. If you follow the .Protect bit with something in quotes, the "Password=" bit is implied. (In other words, they're the same, with or without.)

What I would suggest is go into the code and look closely at the password you wrote in the code and make sure when you're doing it manually you're using the correct spelling, text case etc.

Post back for more ideas if that don't work, but that's the most likely case.

Hope it helps,
Dan
 

elintan

New Member
Joined
Nov 16, 2004
Messages
8
Hi there,
I faced the same problem as did m_woychick, when using this Code. And I am positive that the password that I entered into the Code and the one that I used to manually unprotect the sheet is the same.

How to solve this problem? Else, the worksheets are forever locked!

*sigh*

Thanks in advance!
 

m_woychick

New Member
Joined
Mar 22, 2004
Messages
33
I found a macro on this site to remove a password. I found that the code would work as long as I didn't include the password = part. I think the way the example reads in this posting it is not consistent--when you remove protection and then reset it. Anyway, that's what I did and I'm using it now without problems.

here's a couple of ways to break the password so you can try the macro again:
http://www.mrexcel.com/board2/viewtopic.php?t=92725&highlight=password[/url]
 

Forum statistics

Threads
1,147,510
Messages
5,741,574
Members
423,668
Latest member
Audorin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top