ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Password Protecting/Unprotecting Worksheets using VBA code? (https://www.excelbanter.com/excel-programming/403754-re-password-protecting-unprotecting-worksheets-using-vba-code.html)

Bob Phillips

Password Protecting/Unprotecting Worksheets using VBA code?
 
Of course not. There is nothing unexpected or adverse in what you do, and we
are free to ignore you <bg.

Keep asking, we'll keep answering.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"dim" wrote in message
...
Thanks 'again' Bob,

I hope Im not annoying everyone with all my question, but VBA code is new
to
me, and anything I learn I add into my library so I don't have to ask
again.

Thanks.

"Bob Phillips" wrote:

With Worksheets("Sheet1")
.Unprotect "password"
.Rows(2).Insert
.Protect "password"
End With

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"dim" wrote in message
...
Hi folks,

I have a workbook called Book2. A macro opens Book2, inserts and saves
user
data, then closes Book2.

This all worked fine until I just tried it out with the password
applied
to
Book2. the password is "pswd". When the code attempts to insert a row
into
Book2's sheet as below, it hangs because it cant insert a row when all
the
cells are locked. I thought this might happen, thats why I tested it
now.
But
I dont know the VBA code I need....

Rows("2:2").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown

Can someone please tell me what to add to the code to unprotect the
sheet
using the password, then reprotect it before saving and closing?

Thankyou.








All times are GMT +1. The time now is 08:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com