VBA: What happens to Range objects if user deletes cells?

后端 未结 4 1446
说谎
说谎 2020-12-10 00:47

Suppose I have some module in vba with some variable r of type Range. Suppose that, at some point, I store a Range object there (e.g. the active ce

4条回答
  •  生来不讨喜
    2020-12-10 01:27

    To test if a range object is currently invalid, I use this function:

    Public Function InvalidRangeReference(r As Range) As Boolean    
        On Error Resume Next
        If r.Count = 0 Then
            InvalidRangeReference = Err
        End If    
    End Function
    

提交回复
热议问题