How to Check if an Array is Empty in Excel VBA

When using Arrays in Excel VBA you sometimes need to test whether the array is empty or not.

 Most of the time you could simply test to see if an array is populated by checking the Lbound of the array.  When testing, if you get an error then the array is empty.  Whereas no error suggests the array is not empty. 

So, to test  the Lbound you could use the following the VBA code.  ThisArray would simply be replaced with your array name.

Dim ThisArray() As Long
Dim Nmbr As Long
On Error Resume Next
Err.Clear
Nmbr = LBound(ThisArray)
If Err.Number = 0 Then
'Do this... (array is NOT empty)
Else
'Do this... (array IS empty)
End If

I hope you find this snippet of VBA code useful.

5,777 thoughts on “How to Check if an Array is Empty in Excel VBA

  1. 007 카지노

    Hello my family member! I want to say that this post is amazing,
    nice written and come with almost all important infos.

    I’d like to peer more posts like this .

  2. watermelonmovie.video.blog

    Hey There. I discovered your blog using msn. This is a really
    neatly written article. I’ll make sure to bookmark it and
    come back to read extra of your useful information. Thank you for the post.
    I’ll certainly return.

  3. 카지노 게임

    First of all I would like to say wonderful blog! I had a quick question which I’d like to ask if you don’t mind.
    I was curious to know how you center yourself and clear your mind before writing.
    I have had a hard time clearing my thoughts in getting my ideas out.
    I truly do enjoy writing however it just seems
    like the first 10 to 15 minutes tend to be wasted just trying to figure out how to begin. Any recommendations or tips?
    Kudos!

  4. 인터넷 바카라

    Fantastic goods from you, man. I’ve understand your stuff previous to and you are just too
    great. I really like what you’ve acquired here, certainly
    like what you’re saying and the way in which you say it.
    You make it enjoyable and you still care for to keep it smart.
    I can not wait to read far more from you. This
    is really a tremendous site.

  5. pagodatree23.wordpress.com

    We are a bunch of volunteers and opening a brand new scheme in our community.

    Your website provided us with valuable information to
    work on. You’ve performed a formidable job and our entire neighborhood will probably be thankful to you.

  6. udfauzi.com

    Hi, I do believe this is a great blog. I stumbledupon it 😉 I may return once again since I book-marked it. Money and freedom is the best way to change, may you be rich and continue to help other people.

  7. 넷마블 바카라

    Hey there! I know this is sort of off-topic but I needed
    to ask. Does running a well-established website such as yours take a massive amount work?
    I’m brand new to operating a blog but I do write in my journal every
    day. I’d like to start a blog so I can easily share my own experience and feelings online.
    Please let me know if you have any ideas or tips for new aspiring blog owners.
    Thankyou!

  8. Zenaida

    I think the admin of this web site is in fact working hard in support of his web page, because here every material is quality based stuff.

  9. poboleda.org

    Hi there! This article couldn’t be written any better! Reading through this post reminds me of my previous roommate! He always kept talking about this. I am going to forward this post to him. Fairly certain he’ll have a very good read. I appreciate you for sharing!

  10. Aplicativos Para Btv

    Ponto IPTV a melhor programacao de canais IPTV do Brasil, filmes, series, futebol, lutas, shows, documentarios em alta definicao de imagem e som em SD, HD, FULL HD, 4K. compativel com todos aparelhos do mercado Brasileiro.

  11. toko online 88

    I’m very pleased to find this great site. I wanted to thank you for your time just for this fantastic read!! I definitely really liked every little bit of it and i also have you saved as a favorite to look at new things in your web site.

  12. renovation cuisine rive-sud

    Howdy! This blog post couldn’t be written much better!
    Looking through this article reminds me of my previous roommate!
    He continually kept preaching about this.

    I will forward this article to him. Fairly certain he’s
    going to have a great read. Many thanks for sharing!

  13. download vivoslot apk

    I blog quite often and I seriously appreciate your information. Your article has really peaked my interest. I will bookmark your blog and keep checking for new details about once per week. I opted in for your RSS feed too.

  14. visit website

    It’а†s actually a nice and useful piece of info. I’а†m happy that you simply shared this helpful info with us. Please keep us up to date like this. Thanks for sharing.

  15. vivo slot online

    I would like to thank you for the efforts you’ve put in penning this site. I’m hoping to check out the same high-grade blog posts by you later on as well. In fact, your creative writing abilities has inspired me to get my own, personal website now 😉

Comments are closed.