Check a range is not the entire sheet?

前端 未结 2 2015
没有蜡笔的小新
没有蜡笔的小新 2020-12-22 01:47

I have this function which is trying to detect when a particular cell value changes. The problem is, if the user selects the whole spreadsheet and presses delete, I get an o

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-22 02:14

    Use CountLarge instead of Count

    Private Sub Worksheet_SelectionChange(ByVal target As Range)
        If target.Cells.CountLarge > 1 Then Exit Sub
    
        'Code...
    End Sub
    

    See: MSDN Range.CountLarge Property (Excel)

提交回复
热议问题