DigitalDan
05-27-2008, 06:47 PM
I am pretty new at VBA, and am familiar with the Indirect function of excel, but confused as to how to do it with VBA as it doesn't appear to work.
When the workbook opens, I want to always automatically Lock cells A1:A10, and then unlock only the Range of the cell #'s of which is contained literally in Cells B1 & B2.
For instance if B1="A1", and B2="A5", then I want have Cells A1:A5 unlock themselves. I tried the following below, but it doesn't work for some reason. I have spent hours trying to figure out the simple answer. :)
Private Sub Workbook_Open()
ActiveSheet.Protect Contents:=True, userInterfaceOnly:=True
Range("A1:A10").Select
Range("A1:A10").Locked = True
Range(Range("B1"), Range("B2")).Select
Range(Range("B1"), Range("B2")).Locked = False
End Sub
I would be so happy as this will finish my project once I figure this thing out... Thanks in advance!
When the workbook opens, I want to always automatically Lock cells A1:A10, and then unlock only the Range of the cell #'s of which is contained literally in Cells B1 & B2.
For instance if B1="A1", and B2="A5", then I want have Cells A1:A5 unlock themselves. I tried the following below, but it doesn't work for some reason. I have spent hours trying to figure out the simple answer. :)
Private Sub Workbook_Open()
ActiveSheet.Protect Contents:=True, userInterfaceOnly:=True
Range("A1:A10").Select
Range("A1:A10").Locked = True
Range(Range("B1"), Range("B2")).Select
Range(Range("B1"), Range("B2")).Locked = False
End Sub
I would be so happy as this will finish my project once I figure this thing out... Thanks in advance!