Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jul 2001
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Saving array values (2000 Sr-1)

    Suppose I have an array that takes in values but I want to save those values throughout the use of the program and when the work book is closed. Also, how do I know how big the array is so I can put more data in in anytime i want.

    thanks

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving array values (2000 Sr-1)

    To have the valuse in the array available at any time while the workbook is open, the you need to globally define the array by putting the Dim that defines it outside the procedures in the Declarations section. If you want the values to be available the next time the workbook is opened, then you will need to put them in a worksheet.

    The UBound function will tell you the highest subscript that can be used on the array, and the LBound the lowest. The REDIM statement can be used to change the array's size.

    From what you said, it sounds like you should keep these values in a worksheet. The worksheet can be hidden if you would like.
    Legare Coleman

  3. #3
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving array values (2000 Sr-1)

    Just to clarify something. REDIM will change the size of the array- but it will wipe out the contents of the array. REDIM PRESERVE will keep existing array contents. I'm told it can be inefficient- but it probably doesn't matter much in the scheme of things.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

Posting Permissions

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