Lock all the columns - except A and B and Few values in D,E,F..sheet attached

Priya

New member
Joined
Jan 29, 2014
Messages
16
Reaction score
0
Points
0
Hello,
I am using the attached sheet with macro vb , can anyone please help me by adding a code that will lock all the cells on the sheet except for column A, Column B and d11,e11, d12, e12, d12, d13. I tried record macro but am nt able to do it..many thanks..:help:
 

Attachments

  • updated.xlsm
    389.2 KB · Views: 13

Simi

New member
Joined
Feb 10, 2012
Messages
190
Reaction score
0
Points
0
Location
Utah, USA
Excel Version(s)
Version 2002 Build 12527.20194
Priya,

change your ThisWorkbook code for the open event to be

Code:
Private Sub Workbook_Open()
    Sheets("Sheet1").Activate
    Sheets("Sheet1").Range("A3").Select
    Sheets("Sheet1").Range("A1").EntireColumn.Locked = False
    Sheets("Sheet1").Range("B1").EntireColumn.Locked = False
    Sheets("Sheet1").Range("D11").Locked = False
    Sheets("Sheet1").Range("E11").Locked = False
    Sheets("Sheet1").Range("D12").Locked = False
    Sheets("Sheet1").Range("E12").Locked = False
    Sheets("Sheet1").Range("D13").Locked = False
    Sheets("Sheet1").Range("E13").Locked = False
    Sheets("Sheet1").Protect
    End Sub
 

Priya

New member
Joined
Jan 29, 2014
Messages
16
Reaction score
0
Points
0
Oh my GOD!! lol..Simi..I thought I was acting too silly asking so many questions on one thread so posted a new thread!you were kind enough to still answer! thanks a ton!! have a nice day!you ROCK! :flypig:
 

Priya

New member
Joined
Jan 29, 2014
Messages
16
Reaction score
0
Points
0
Hi Simi,

When am using the above code the macro is not working and the error is on the code line :
.Range("A3:A" & .Cells(.Rows.Count, "A").End(xlUp).Row).Sort Key1:=.Range("A2"), Order1:=xlAscending, Header:=xlNo
 

Simi

New member
Joined
Feb 10, 2012
Messages
190
Reaction score
0
Points
0
Location
Utah, USA
Excel Version(s)
Version 2002 Build 12527.20194
Im just going to guess at this that the sort key is incorrect as it is outside of the selected range to sort. change the "A2" to "A3" and it should clear up your problem.
 
Top