Test if range exists in VBA

前端 未结 4 1653
滥情空心
滥情空心 2020-12-17 17:14

I have a dynamically defined named range in my excel ss that grabs data out of a table based on a start date and an end date like this

=OFFSET(Time!$A$1,IFER         


        
4条回答
  •  悲哀的现实
    2020-12-17 17:38

    You can replicate the match in your VBA to count before using the range how many rows you would have, or you can use error handling:

    On Error Resume Next
    
    Debug.Print range("DateRangeData").Rows.Count
    
    If Err = 1004 Then
        MsgBox "Range Empty"
        Exit Sub
    Else
        MsgBox "Range full"
    End If
    
    Err.Clear
    On Error GoTo 0
    

提交回复
热议问题