roscoe
Well-known Member
- Joined
- Jun 4, 2002
- Messages
- 1,062
- Office Version
- 365
- Platform
- Windows
- MacOS
I have a user form that reads in data from a worksheet and populates a combo box (after converting time values into strings). I have a few global variables (within the context of the user form) that I "dim" at the top of the user form module that allows them to stay active through the various routines in the user form. So far so good
Problem is now I need to do more than load the data into the combobox, so I thought I'd load them into an array at the same time. Works fine when I load it. But when I select a button on the userform (in this case to add more data to the array I just created), the array has been blitzed and I get an error.
What I tried to do that has always worked in the past was DIM "array" as VARIANT, then redim ARRAY(as applicable) when I first fill it. I then load the user form. Next step is to add data to the array by clicking on a button. The plan was to "redim preserve" to make it bigger and then fill the new line, but I never got there...it was empty as soon as I clicked on the button and executed that sub.
How do I create an array in the user form and keep it alive until I unload the user form? Is there a trick to the DIM statement or how to set the dimensions or ... to make this work?
Thanks in advance
Problem is now I need to do more than load the data into the combobox, so I thought I'd load them into an array at the same time. Works fine when I load it. But when I select a button on the userform (in this case to add more data to the array I just created), the array has been blitzed and I get an error.
What I tried to do that has always worked in the past was DIM "array" as VARIANT, then redim ARRAY(as applicable) when I first fill it. I then load the user form. Next step is to add data to the array by clicking on a button. The plan was to "redim preserve" to make it bigger and then fill the new line, but I never got there...it was empty as soon as I clicked on the button and executed that sub.
How do I create an array in the user form and keep it alive until I unload the user form? Is there a trick to the DIM statement or how to set the dimensions or ... to make this work?
Thanks in advance