How can I determine if my collection is empty or not?

TheRedCardinal

Board Regular
Joined
Jul 11, 2019
Messages
243
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
I have a procedure that puts item numbers that need to be dealt with later into a collection.

Then it re-dims an array based on the size of that collection.

For the first time, there was nothing to be dealt with, and so my collection is empty (but has still been defined).

I have tried:

  1. If Not Isempty(Collection)
  2. If Not IsEmpty(Collection.AllItems)
  3. If CountRows(Collection) > 0

But I get an error with each one.

Is there a better way to test the condition?
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
If the collection has been initialized, you can test its Count property. Otherwise test if the variable Is Nothing.
 
Upvote 0

Forum statistics

Threads
1,215,310
Messages
6,124,181
Members
449,147
Latest member
sweetkt327

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