Consulting

Results 1 to 3 of 3

Thread: Protect spesific columns from deleting

  1. #1

    Protect spesific columns from deleting

    Hello,
    I want to protect columns B to AA from deleting and i can edit of them but there are more columns after AA.
    How can i do that?
    Best Regards

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Lock at least one cell in each of the columns. Protect the sheet but allow column deletion.

  3. #3
    VBAX Tutor MINCUS1308's Avatar
    Joined
    Jun 2014
    Location
    UNDER MY DESK
    Posts
    254
    This code will lock the cells in the range. You wont be able to select, delete or edit them.

    Sub Macro1()
        
        'SET ERROR HANDELING
        On Error Resume Next
        
        'SETTING ALL CELLS TO UNLOCKED BECAUSE THE DEFAULT IS LOCKED
        Cells.Select
        Selection.Locked = False
        
        'FORMATTING THE DESIRED RANGED TO LOCKED
        Range( _
            "B:B,C:C,D:D,E:E,F:F,G:G,H:H,I:I,J:J,K:K,L:L,M:M,N:N,O:O,P:P,Q:Q,R:R,S:S,T:T,U:U,V:V,W:W,X:X,Y:Y,Z:Z,AA:AA" _
        ).Locked = True
        
        'SETTING THE WORKSHEETS PROTECTION
        ActiveSheet.Protect
        
    End Sub
    - I HAVE NO IDEA WHAT I'M DOING

Posting Permissions

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