Unlocking range of cells in excel selected by cellname Office 2007
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"开发者_JS百科
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?
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!
You don't need to go through every cell in a Range
.
Simply...
Range("myRangeName").Select
Selection.Locked = False
精彩评论