Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Business Applications Business Applications
Search Search
Search for:
Tech Support Guy > > >

Solved: error "400" running an Excel macro


(!)

rcobos's Avatar
rcobos rcobos is offline
Computer Specs
Member with 3 posts.
THREAD STARTER
 
Join Date: Jul 2012
Experience: Beginner
05-Jul-2012, 03:13 PM #1
Red face Solved: error "400" running an Excel macro
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
Rollin_Again's Avatar
Member with 4,686 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Advanced
06-Jul-2012, 11:09 PM #2
So just add a couple of lines of code to first unprotect the sheet, then clear the contents, the protect the sheet again.

Rollin
ssye894's Avatar
ssye894 ssye894 is offline
Member with 7 posts.
 
Join Date: Jul 2012
07-Jul-2012, 01:31 AM #3
rcobos's Avatar
rcobos rcobos is offline
Computer Specs
Member with 3 posts.
THREAD STARTER
 
Join Date: Jul 2012
Experience: Beginner
09-Jul-2012, 10:09 AM #4
Thumbs up @ Rollin
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..
GeorgeJ's Avatar
GeorgeJ GeorgeJ is offline
Member with 144 posts.
 
Join Date: Jan 2012
Location: Scotland
Experience: Intermediate
09-Jul-2012, 11:03 AM #5
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's Avatar
rcobos rcobos is offline
Computer Specs
Member with 3 posts.
THREAD STARTER
 
Join Date: Jul 2012
Experience: Beginner
09-Jul-2012, 03:17 PM #6
@ GerogeJ
Thank you very much for your help, worked like a charm !!!

Thank for your time !

Rod
Rollin_Again's Avatar
Member with 4,686 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Advanced
09-Jul-2012, 06:34 PM #7
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
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
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.


Tags
400, error, excel 10, macro

(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑