VBA - 循环保护工作表时会自动出现“删除?”消息

VBA - 循环保护工作表时会自动出现“删除?”消息

在循环期间(对于 ThisWorkbook.Worksheets 中的每个 ws,代码如下)... 有 38 张表。其中两张弹出了此消息..?? 这是来自 Excel 的消息,不是我.... 为什么?这是什么意思?

 n = Worksheets.count:  count_X = 0
 For Each ws In ThisWorkbook.Worksheets
     ws.Unprotect Password:=str_PW
     ws.Protect Password:=PW, UserInterfaceOnly:=True, DrawingObjects:=False
     Application.ScreenUpdating = True:  Application.EnableEvents = True:  Application.Cursor = xlWait
     ws.EnableSelection = xlUnlockedCells
     count_X = count_X + 1
     If (count_X = n) Then Sleep 88
     Sheets("XX").Range("E7").Value = count_X:                      Sleep 11
     If (count_X = n) Then Sleep 444

     MsgBox "Protect... " & ws.Name   '<<< This is my way of finding out which two sheets!! OMG...

     Application.ScreenUpdating = False:  Application.EnableEvents = False:  Application.Cursor = xlWait
 Next ws

 Sheets

在此处输入图片描述

相关内容