Private Sub Workbook_Open()
For Each sht In Worksheets sht.unprotect
sht.Columns("G:I").EntireColumn.Hidden = True sht.protect
Next
End Sub
For Each sht In Worksheets sht.unprotect
sht.Columns("G:I").EntireColumn.Hidden = True sht.protect
Next
End Sub
简单的办法就是设置那两个单元格的属性,下面提供通用性好的代码 Sub hid()
With ActiveSheet
.Unprotect
.Cells.Locked = False
.Columns("A:B").Locked = True
Application.Intersect(.Rows(1), .Columns("A:B")).Locked = False
.Protect
End With
End Sub
With ActiveSheet
.Unprotect
.Cells.Locked = False
.Columns("A:B").Locked = True
Application.Intersect(.Rows(1), .Columns("A:B")).Locked = False
.Protect
End With
End Sub