how to check if array is empty?

amigos

Active Member
Joined
Sep 23, 2003
Messages
407
this code is for test only and to show you what I need:

Sub TEST()

Dim ar(0 To 3) As String
Dim arf() As String

ar(0) = "a"
ar(1) = "a"
ar(2) = "a"
ar(3) = "a"

arf = Filter(ar(), "b")

MsgBox arf(0)

End Sub

arf() will be obviously an empty array and I want to be able to check that before I will run MsgBox and receive error....

any ideas???

thanks in advance.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
How about this?
Code:
If UBound(arf) = -1 Then
     MsgBox "The array arf is empty"
End If
 
Upvote 0

Forum statistics

Threads
1,207,012
Messages
6,076,148
Members
446,187
Latest member
LMill

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top