PDA

View Full Version : Posting value to Cells from VBA, where Cell are protected?



deyken
01-13-2012, 07:30 AM
Hi Guys,

I wrote a rather involved Excel UI that collects plenty data from several SQL Server databases accross our network. I added a User form to process some of this data before it gets added into the Excel Workbook.

What I tried to do is to protect the workbook/worksheet, thereby forcing the company users to have to use my User Form to complete the worksheet, but alas, when I try to code to protected cells I get the same error from Excel that the cells are locked. Unlocking the worksheet works, but now I run the risk again that users would edit the cells in the workbook without using my UI Form.

Is there a way to keept the actual workbook protected (stops all formatting and edits at all times), but I can still post values from VBA to those cells?

Looking forward to any assistance!

Kenneth Hobs
01-13-2012, 11:00 AM
Worksheets("Sheet1").Protect "Kenneth", UserInterfaceOnly:=True

deyken
01-16-2012, 12:43 AM
Hi Kenneth,

It worked 100% - Thank you very very much!