View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Reg Reg is offline
external usenet poster
 
Posts: 48
Default VBA code and protected cells

Try this

1. Unprotect the *workbook*
2. Unprotect the *worksheet(s)*
3. Does the code now run properly/as expected?

If it does then the problem is caused by the macro trying to update a
something that is protected the solution is to a) change the macro so it
doesnt do any updates or b) change the macro to do the unprotect (ask for a
password, unprotect, do update, re-protect with same password) or c) run the
worksheet without protection or d) change the macro to do the unprotect and
hard code the password into the macro

I prefer b) but it takes the most work to do properly so you need to decide
if one of the alternates is better for your product


hth
Reg

"manni" wrote:

What kind of details do you need? Sorry, I'm new to all this.

I tried deleting the original code, unprotected the sheet, put in the code,
then i unlocked the cells and then i re-protected the sheet again. I clearly
didn't do something right because it got the same message "Run-time error
'1004': Unable to set the MergeCells property of the Range class"

I have no idea what that means...

It asks me if I want to debug and then the view code pops up with
"ma.MergeCells = False" highlighted in yellow.

Thoughts??

"Reg" wrote:

Without having some more detail this is a shot in the dark - but VBA will
error if your code is trying to make changes to a protected sheet, you need
to unprotect, run the code, re-protect it.

hth
RegMigrant

"manni" wrote:

Hello -

I created a form template in excel and I unlocked various cells and then
protected the sheet so that users who completed the form would only be able
to make changes to specific areas.

I decided later that in "free answer" sections I wanted the merged cells to
expand to fit the data the person enters. So, I wrote a VBA code based on a
search that I'd performed on here.

Individually both of the above worked. But after writing the VBA code and
then protecting the sheet, I no longer had access to click on the free
response area (the area with the code). So, I went back in and "unlocked"
those cells and protected the sheet again. Unfortunately, I seem to have
done something wrong, because I get an error message when data is entered in
this section, the cell won't expand and it talks about "debugging" and brings
up the "view code" area.

Could someone please help me??