Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Sheet1.Unprotect Password:="password"
Lr = Rows.Count
Range("G3:G" & Lr).Locked = True
Range("K3:K" & Lr).Locked = True
Sheet1.Protect Password:="password"
End Sub
I have to protect whole column.... and it will be OK with macro....
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Application.ScreenUpdating = False
Sheet1.Unprotect Password:="password"
Lr = Rows.Count
Range("G3:G" & Lr).Select
Selection.SpecialCells(xlCellTypeConstants, 23).Select
Selection.Locked = True
Range("G3:G" & Lr).Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Locked = False
Range("K3:K" & Lr).Select
Selection.SpecialCells(xlCellTypeConstants, 23).Select
Selection.Locked = True
Range("K3:K" & Lr).Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Locked = False
Sheet1.Protect Password:="password"
Application.ScreenUpdating = True
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
on error exit sub
Application.ScreenUpdating = False
Sheet1.Unprotect Password:="password"
Lr = Rows.Count
Range("G3:G" & Lr).Select
Selection.SpecialCells(xlCellTypeConstants, 23).Select
Selection.Locked = True
Range("G3:G" & Lr).Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Locked = False
Range("K3:K" & Lr).Select
Selection.SpecialCells(xlCellTypeConstants, 23).Select
Selection.Locked = True
Range("K3:K" & Lr).Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Locked = False
Sheet1.Protect Password:="password"
Application.ScreenUpdating = True
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
On Error Goto Err
Application.ScreenUpdating = False
Sheet1.Unprotect Password:="password"
Lr = Rows.Count
Range("G3:G" & Lr).Select
Selection.SpecialCells(xlCellTypeConstants, 23).Select
Selection.Locked = True
Range("G3:G" & Lr).Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Locked = False
Range("K3:K" & Lr).Select
Selection.SpecialCells(xlCellTypeConstants, 23).Select
Selection.Locked = True
Range("K3:K" & Lr).Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Locked = False
Sheet1.Protect Password:="password"
Application.ScreenUpdating = True
Err:
Exit Sub
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
On Error Goto Err
Application.ScreenUpdating = False
Sheet1.Unprotect Password:="password"
Lr = Rows.Count
Range("G3:G" & Lr).Select
Selection.SpecialCells(xlCellTypeConstants, 23).Select
Selection.Locked = True
Range("G3:G" & Lr).Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Locked = False
Range("K3:K" & Lr).Select
Selection.SpecialCells(xlCellTypeConstants, 23).Select
Selection.Locked = True
Range("K3:K" & Lr).Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Locked = False
Sheet1.Protect Password:="password", AllowFiltering:=True
Application.ScreenUpdating = True
Err:
Exit Sub
End Sub