Detecting empty array

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
2,094
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Dim fn as Variant
I've filtered my array and this may have removed all items.
But IsEmpty(fn) returns False and ? fn(0) gives subscript out of range.
Error handling works but is there a correct 'Excel' way to handle this?
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Problem is kinda sketchy. Can't tel if fn is the initial array or the filtered one. Or if the same variable is used for both.
A variant is both 0 and "" when it is initialized but I'm not sure if ?fn(0) should return that error if the only value in the array variable is "" or 0.
Or maybe Option Base 1 is set, which would make the first element 1, not 0.
Or I misunderstood what the problem is.
 
Upvote 0
Thanks for the replies, Ubound = -1 was what I'd missed. And then For e = Lbound(fn) to Ubound(fn) seems to do the trick.
 
Upvote 0
@Joe4 & @Micron - what Peter picked up on and I certainly didn't was that the OP must have used VBA filter of an array.
Something like this:
Rich (BB code):
   filterArr = Filter(arr, "Value_to_Filter_On")
If nothing is found it produces this:
1734489940615.png


Note:
IsEmpty produced False
IsArray produced True
 
Upvote 0

Forum statistics

Threads
1,224,698
Messages
6,180,424
Members
452,981
Latest member
MarkS1234

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