+ Reply to Thread
Results 1 to 11 of 11

How to tell if array is empty....mine is not working

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    How to tell if array is empty....mine is not working

    I have the following code.............it has a run time error when i try to determine the array is empty.........any ideas why this is ahappening?
    Attached Files Attached Files

  2. #2
    Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2010
    Posts
    500

    Re: How to tell if array is empty....mine is not working

    I don't know much about arrays, but isn't "isarrayempty" a boolean?

  3. #3
    Registered User
    Join Date
    07-27-2010
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: How to tell if array is empty....mine is not working

    Hi,

    I've had this problem too. Check out the IsArrayEmpty function here:

    http://www.cpearson.com/excel/vbaarrays.htm

    Cheers,
    Dom

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: How to tell if array is empty....mine is not working

    Hi welchs101
    Replace this code
    Please Login or Register  to view this content.
    with this code
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  5. #5
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: How to tell if array is empty....mine is not working

    thanks.

    question: if i have the following code.......in this code the array is empty because i have not done anything with it yet.........i run your code on it and i get a type mismatch error. Am i using it wrong. i know i have not assigned anything to the array yet but can i only use the array after i assign and then take away things from it.



    Please Login or Register  to view this content.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: How to tell if array is empty....mine is not working

    You declared it as a variant, not an array.
    Everyone who confuses correlation and causation ends up dead.

  7. #7
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: How to tell if array is empty....mine is not working

    romperstomper............thanks.

    Question:
    For lngrow < 6 the sht_array never gets anything assigned to it. Since i assigned it as variant rather than array.........what would you recommend i do to test to see if any assignment had been made.

    Please Login or Register  to view this content.


    actually, i was just thinking ........if lngrow>6 then i can handle this case via the already present IF statements.

    Thanks for all the inputs.

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: How to tell if array is empty....mine is not working

    You can test using IsArray.

  9. #9
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: How to tell if array is empty....mine is not working


    Please Login or Register  to view this content.



  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: How to tell if array is empty....mine is not working

    Is there a question there somewhere for someone?

  11. #11
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: How to tell if array is empty....mine is not working

    romperstomper,

    thanks! that worked. i checked both cases and it worked. thanks.



    snb,
    i ran the code you sent...........i think its trying to tell me something useful but i am not sure what. cant seem to match up what is telling me with what is on sheet1.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1