【发布时间】:2017-07-25 17:52:11
【问题描述】:
我想创建一个宏来根据 Locked range 属性锁定/解锁单元格,但我无法触发语句的 Case Null 部分(前 2 个工作正常)
Sub Lockunlockselection()
Dim c As Range
Dim wb As Workbook
Dim ws As Worksheet
'Dim lck As String
'Dim unlck As String
Set wb = ActiveWorkbook
Set ws = wb.ActiveSheet
'lck = Empty
'unlck = Empty
Set c = selection
Select Case c.Locked
Case False
c.Locked = True
msgbox "Selection " & c.Address & " is now locked!", vbInformation, Date
Case True
c.Locked = False
msgbox "Selection " & c.Address & " is now unlocked!", vbInformation, Date
Case Null ' this would be if mix of locked and unlocked
c.Locked = True
msgbox "Mix of locked and unlocked cells!" & vbLf & vbLf & "Cells are all now locked!", vbInformation + vbExclamation, "Info.."
End Select
End Sub
为什么没有触发?
谢谢!
【问题讨论】: