LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 460
Default Variant Array retaining data in it after procedure finished

Yep, that'll be it. The variable is declared at the top of the module -
outside of the procedure. I didn't know that that meant it (and others) were
then live throughout the life of the workbook... oh dear....

Anyway. Cheers.

Doug

"Tom Ogilvy" wrote:

Sounds like the array is declared outside a procedure, so it is a global
variable and therefore its lifetime is the lifetime of the open workbook.
Or, you are using some type of global counter as the basis for resizing the
array and that is the item that is retaining its value.

--
Regards,
Tom Ogilvy



"Doug" wrote in message
...
Hi,

I hope someone can help cos I am stuck!

I have a procedure that creates an array (variant). The variant/array's

size
is dependant on various criteria it encounters at run-time so I'm using
'redim preserve' each time during a loop to make it bigger. At the end of

the
code running, the array is typically (20 * 2* 76) parts big, and I'm done
with using it - the data in it's been used etc.

My problem is that; I open Excel. Run the procedure. It works perfectly. I
run the procedure again, the variable is twice as big as it was before at

the
end of the procedure = somehow, it's kept the data in it after the code

has
stopped.

How is that possible?? It works fine if I close Excel again & run it

again,
obviously but all the books I've read say that the life of a variable only
exists whilst code is running...

Code execution is stopped by an 'Exit Sub' in front of a load of things

that
error trappers Goto & then Return to the code above it. The code stops as

it
should at the 'Exit Sub'.

Any help much appreciated as always.

Thanks,

Steven Douglas




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Coercing a variant into an array Alex T Excel Programming 1 November 18th 04 09:54 PM
Remove First Row from Variant Array FAST? R Avery Excel Programming 18 August 20th 04 03:29 PM
Variant Array Steph[_3_] Excel Programming 1 June 2nd 04 01:29 AM
basic variant to array conversion Jeff Sward Excel Programming 1 January 26th 04 07:59 PM
variant array containing cel adresses convert to actual ranges-array Peter[_21_] Excel Programming 5 December 10th 03 09:50 PM


All times are GMT +1. The time now is 04:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"