PDA

View Full Version : Protect spesific columns from deleting



cagataybaser
09-18-2014, 07:25 AM
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

Kenneth Hobs
09-18-2014, 07:56 AM
Lock at least one cell in each of the columns. Protect the sheet but allow column deletion.

MINCUS1308
09-18-2014, 08:02 AM
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