Results 1 to 5 of 5

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

  1. #1

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



    Register for a FREE account, and/
    or Log in to avoid these ads!

    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..
    Attached Files Attached Files

  2. #2
    Conjurer Simi's Avatar
    Join Date
    Feb 2012
    Location
    Utah, USA
    Posts
    187
    Articles
    0
    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

  3. #3
    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!

  4. #4
    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

  5. #5
    Conjurer Simi's Avatar
    Join Date
    Feb 2012
    Location
    Utah, USA
    Posts
    187
    Articles
    0
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •