这与KopBuH的答案基本相同,但我更喜欢这种循环/布尔赋值方法...
Function ElementsSame(arr As Variant) As Boolean
Dim l As Long
ElementsSame = True
For l = 1 To UBound(arr)
If arr(0) <> arr(l) Then
ElementsSame = False
Exit For
End If
Next l
End Function
Run Code Online (Sandbox Code Playgroud)