以下保护工作薄中所有工作表中的非空单元格代码怎么不管用?请大神帮忙。
Private Sub Workbook_BeforeClose(Cancel As Boolean) '关闭工作簿前保护所有工作表 IName = ActiveSheet.Name For i = 1 To Sheets.Count Sheets(i).Select If Application.CountA(Range("A:XFD")) = 0 Then GoTo 100 ActiveSheet.Unprotect Cells.Locked = False Cells.FormulaHidden = False Set quyu = Range([A1], ActiveCell.SpecialCells(xlLastCell)) For Each icell In quyu If icell.HasFormula Or icell.Value <> "" Then icell.Locked = True icell.FormulaHidden = True End If Next icell ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True Range("A1").Select 100 Next i Sheets(IName).Select End Sub
|