Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unprotecting a sheet - Run Time Error 1004

Status
Not open for further replies.

MissyEd

IS-IT--Management
Feb 14, 2000
303
GB
Hi all

I have a worksheet with a command button on it called cmdAddRow. Basically, it adds a row to the worksheet at a specified point. This point changes depending on how many rows of data are already in the sheet. e.g

row 1 £200.00
row 2 £175.99
total £275.99

So I want to add a row between row 2 and total row. I can do this OK, but once I put protection on the worksheet I get run time error 1004 when unprotecting the sheet...

I dont want the user adding values wherever they like, so I need to protect the sheet, unprotect it to add the row, unlock the cells the user can enter data into, then protect the sheet once again.

I have tried activeworkbooks.unprotect "password" and worksheets("sheet1").unprotect password:="password" and worksheets("sheet1").unprotect "password" and
Set myworksheet = Worksheets("cash payments")
myworksheet.Unprotect Password:="password"
to no avail.

Suprisingly enough, I can unlock the sheets no problem from VB5 which I use to import the data. I use xlSheet.Unprotect ("password") and this works np. I then protect it with xlSheet.Protect Password:="password"

HELP !!! :) Missy Ed
Looking to exchange ideas and tips on VB and MS Access development as well as office 97 development. Drop me a line: msedbbw@hotmail.com
 
Thanks to everyone who emailed me the answer to this: apparantly, I had to set the command button to not take focus on click.....some things are not so obvious :) Missy Ed
Looking to exchange ideas and tips on VB and MS Access development as well as office 97 development. Drop me a line: msedbbw@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top