0
我正在嘗試編寫消息的代碼,以便在複選框被選中時彈出。我的電子表格有很多複選框,我只希望它爲H列中的複選框執行此操作。我相信最好的方法可能是使用類似以下代碼的方式將宏指派給所有使用vba的複選框(除了這不是工作):vba - Msg if if if checked - but not if unchecked
ActiveSheet.Shapes.Range(Array("h9:h89")).Select
Selection.OnAction = "Sheet4.Checkbox"
我的第二個問題是,我只希望消息彈出時檢查,而不是未選中時。當宏被分配到手動時,以下工作,但爲檢查和取消選中。註釋掉的部分是我嘗試過的一些事情的例子。我相信他們是ActiveX複選框。
Sub Checkbox()
' Dim rangeVar As Range
'
' rangeVar = ("h9:h89")
'
'With rangeVar
' If WorksheetFunction.Or(.Cells) = True Then
MsgBox ("Are you sure you want to check this box?")
Exit Sub
' End If
'End With
' Dim chk As Checkbox
'
' For Each chk In rangeVar
' If chk.Value = True Then
' MsgBox ("Are you sure you want to check this box?")
' Exit Sub
' End If
' Next chk
End Sub
謝謝!