Handle Error 9 when there is an Empty Array

后端 未结 8 1650
无人共我
无人共我 2021-01-02 17:43

I am writing a script that will loop through an Excel spreadsheet and find if there are duplicates of selected cells. If there are duplicates then the function will return

8条回答
  •  一向
    一向 (楼主)
    2021-01-02 18:20

    Try this to check an empty array:

    Dim arr() As String
    
    If (Not arr) = -1 Then
       Debug.Print "empty"
    Else
       Debug.Print "UBound is " & UBound(X)
    End If  
    

    HTH!

提交回复
热议问题