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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Protecting Excel Sheet with Formatting 1

Status
Not open for further replies.

Allilue

Technical User
Joined
Sep 14, 2000
Messages
189
Location
GB
Hello,

I have created a button that adds rows to my spreadsheet table. Since the sheet is protected, I've done a

Sheet1.Unprotect ("password") and
Sheet1.Protect ("password") at the end to re-protect.

However, I've formatted the original protection to allow users to format cells, columns and rows.

Can someone help me with the code to include those "allowances" as the Protect code automatically sets this to not allow these?

Thanks,
Allison
 
This works for excel xp and higher. Set protection properties when protecting the sheet (see excel vba help for details):
Sheet1.Protect AllowFormattingCells:=True

combo
 
Thanks, so this is what I've tried, but something is still going wrong:

Sheet1.Protect([Password], [AllowFormattingCells], [AllowFormattingColumns], [AllowFormattingRows]) = True

Can you help here please?
Thanks,
Allison
 
This is (slightly modified) an example from excel vba help:
Code:
Sheet1.Protect Scenarios:=True, UserInterfaceOnly:=True
Just see what parameters you need and how to set them (well, the latter you have above).

combo
 
Hi,

I've tried going through the Help function, and have now come up with

Sheet1.Protect("gogetem", AllowFormattingCells, AllowFormattingColumns, AllowFormattingRows) = True

But I get a compile error now...

Getting closer... hopefully!! ;-)

 
Try
Code:
Sheet1.Protect Password:="yourpassword", AllowFormattingCells := True, AllowFormattingColumns := Ture, AllowFormattingRows := True


-V
 
PERFECT!!!! Thanks for your help, all!!! :-)
 
Last one, I promise!!

What if I also want to be able to resize a picture that I've pasted into a textbox while my worksheet is protected? is there a specific "AllowObject...." term for that? I've looked in the Help and cannot figure out which one I need to use.

THANKS AGAIN!!
 




Please post NEW questions in a NEW THREAD.

Skip,

[glasses] To be safe on the [red]FOURTH[/red],
Don't take a [red]FIFTH[/red] on the [red]THIRD[/red]
Or you might not come [red]FORTH[/red] on the [red]FIFTH[/red]
[red][highlight blue]FORTH[/highlight][/red][white][highlight red]WITH[/highlight][/white] [tongue]
 
The reason for that is because it's hard for other people to look up answers when there are bunches of unrelated ones in the same thread. The title of the thread should give some idea of the material in it, so you can see that your last question is off topic when the title is taken into account.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top