Results 1 to 2 of 2

Thread: Array problem

  1. #1
    Join Date
    Jan 2004
    Posts
    5

    Unanswered: Array problem

    When you define an array as Dim Array() as Variant, you simply set up a placeholder for a future array.

    How do you get excel to recognized that fact. I've got a a routine that needs to recognized that if the array has not been filled or ReDim'ed, it needs to exit the sub. Unfortunately, I can't seem to find the right function to do this. IsEmpty and IsNull do not work.

    Any ideas

  2. #2
    Join Date
    Mar 2004
    Location
    Minnesota, USA, Earth
    Posts
    65

    Re: Array problem

    Originally posted by Jim Lowe
    When you define an array as Dim Array() as Variant, you simply set up a placeholder for a future array.

    How do you get excel to recognized that fact. I've got a a routine that needs to recognized that if the array has not been filled or ReDim'ed, it needs to exit the sub. Unfortunately, I can't seem to find the right function to do this. IsEmpty and IsNull do not work.

    Any ideas
    Hi,

    I'm not familiar with any VBA function that keeps track of changes to an array. So, this isn't a function, but how about adding the variable dim ReDimmedArray as Boolean. Right after you initially dim the array set ReDimmedArray = FALSE. Right after the code redimentions the array, set ReDimmedArray = TRUE. Also, when data has been entered into the array, set ReDimmedArray = TRUE. So, this variable will start out as False, but whenever the array has been redimentioned or filled with data, ReDimmedArray will = TRUE.

    In the routine you mentioned, set-up an IF...THEN...ELSE to test ReDimmedArray = TRUE (or FALSE).

    I don't know the scope of the array, but whatever it is, I would set up ReDimmedArray in the same scope.

    Hope this is helpful,
    Mike

Posting Permissions

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