Syntax for a macro to unprotect a union of cells

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Have a union of a hundred cells similar to the line of code below.
set cell???? = range("??")
Set allcell = Application.Union(cell1720, cell1721, cell1722)
allcells.Value = ""
allcells.Font.ColorIndex = 0

What is the syntax to unprotect all cells in "allcell"
 
Entered "allcells.Locked = False" into the macro and got the following result
in Excell 2003.

Run-time error'1004':

Unable to set the Locked property of the Range class.
 
Say this is in Sheet1. Try

Sheets("Sheet1").Unprotect
allcells.locked = False
Sheets("Sheet1").Protect

If there is a password involved, you will need to supply it as a
parameter to the protect/unprotect methods:
Sheets("Sheet1").Unprotect("MyPassword")

Hth

-John Coleman
 
Tried the code as stand alone
got a run-time error 424: object required.
Inserted the code at the end of the macro that defines "Allcells" as a union
and got the same 1004 error.

The following 2 lines of code do work in the same macro that defines
"Allcells"
allcells.Value = "" ' clear all cells
allcells.Font.ColorIndex = 5 'set all cells to blue

Excell 2003 Vesta. "Allcells" is over 100 cells, all of which are merged
cells.
Changing the protection cell by cell one at a time does work and is a
workaround. The workaround is slow.

Within nested Do loops
Sheets("sheet1").range("b2").offset(I*5,J*5).sellect
Selection.Locked = False

roypeck
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top