Solved: error "400" running an Excel macro

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

rcobos

Thread Starter
Joined
Jul 5, 2012
Messages
3
Hi Guys:

I have created a macro( 2 line macro actually) that goes through my workbook and it supposed to clear the value from cells b1:b68 on main page. When I try to run the macro with the sheet protected I get a pop up that just says "400" in it with a red circle that has a white "X" through it, whit the sheet unprotected works perfectly !. Because it is a survey I need to protect teh content, to be manipulated by many. Can somebody give a clue? Here is the code:

Public Sub Clear()
Sheet1.Cells.Range("B17:B68").ClearContents
End Sub


Windows 7
MExcel 2010

Many thanks

Rod
 
Joined
Sep 4, 2003
Messages
4,912
So just add a couple of lines of code to first unprotect the sheet, then clear the contents, the protect the sheet again.

Rollin
 

rcobos

Thread Starter
Joined
Jul 5, 2012
Messages
3
Thank you very much.......I tried it but when you run the macro, it ask you to input the password to unprotected the sheet, then i have to give everybody the password....... there is no point to protect it............ so back to square one..:(
 
Joined
Jan 16, 2012
Messages
144
Could you not make the VBA unlock the sheet by providing the password
do what you want
then lock the sheet again using the password

Then the user wouldn't know the password if the macro was locked too, possibly ThisWorkbook.Protect Password:="yourpassword"
 

rcobos

Thread Starter
Joined
Jul 5, 2012
Messages
3
Thank you very much for your help, worked like a charm !!!

Thank for your time !

Rod
 
Joined
Sep 4, 2003
Messages
4,912
Keep in mind that if the macro code is attached to the workbook you are sending out others will be able to view the code and retrieve the password unless you password protect the code module.

Rollin
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top