views:

23

answers:

1

I have 3 cells which are merged with each other and are referenced to with a given cellname (for example "foo").

I now want to unlock these cells with the locked attribute.

The lock in the following code will not work, but the value will be successfully assigned to the cell:

Workbooks(loadedSheetName).Worksheets("foo").Range("bar").Locked = False
Workbooks(loadedSheetName).Worksheets("foo").Range("bar") = "foo value"

What will work is referencing the cells by "coordinates" but is not really an option for me:

Workbooks(loadedSheetName).Worksheets("foo").Range("B3:E3").Locked = False

Is there any possibility to select some merged cells by name and set the locked attribute to false?

+2  A: 

The following code works OK in my Excel 2007


Sub aa()
    Dim ce As Range
    Application.ScreenUpdating = False ''# screen flicker off
    ActiveSheet.Unprotect Password:=""
    For Each ce In Range("rng")
        ce.MergeArea.Locked = "False"
    Next ce
    ActiveSheet.Protect Password:=""
End Sub

HTH!

belisarius
thx this works :-)
echox