Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA code to "reset" application run and empty preserved arrays

Hi,

I've been helping write some VBA code which is executed from a button
on an excel worksheet. Data is read in from the sheet, calculations
are performed in multiple modules (public variables). The problem is
that as some of the arrays which hold the data are dimensioned using
Redim Preserve, which means that when the program ends, the data is
still in the arrays.

If the program is run a 2nd time from the button on the worksheet,
lots of errors are generated in the program, as the arrays are full of
data from the first run. If "reset" is clicked in the VB editor, the
arrays empty & the code runs fine. Is there a way to code this
'reset' button & empty the arrays?

Cheers,
Kate

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default VBA code to "reset" application run and empty preserved arrays

Look in the Excel online help for the keyword "erase" - gets rid of arrays....

--
www.alignment-systems.com


" wrote:

Hi,

I've been helping write some VBA code which is executed from a button
on an excel worksheet. Data is read in from the sheet, calculations
are performed in multiple modules (public variables). The problem is
that as some of the arrays which hold the data are dimensioned using
Redim Preserve, which means that when the program ends, the data is
still in the arrays.

If the program is run a 2nd time from the button on the worksheet,
lots of errors are generated in the program, as the arrays are full of
data from the first run. If "reset" is clicked in the VB editor, the
arrays empty & the code runs fine. Is there a way to code this
'reset' button & empty the arrays?

Cheers,
Kate


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default VBA code to "reset" application run and empty preserved arrays

Kate,
Whilst I would not recommend it, there is End. However, this is rather
abrupt termination of code and clearing of variable.
Go John's way of explicitly Erasing each array, unless you want to
<probably cause more problems than it solves with End, which is the code
equivalent of the Reset button.

NickHK

wrote in message
oups.com...
Hi,

I've been helping write some VBA code which is executed from a button
on an excel worksheet. Data is read in from the sheet, calculations
are performed in multiple modules (public variables). The problem is
that as some of the arrays which hold the data are dimensioned using
Redim Preserve, which means that when the program ends, the data is
still in the arrays.

If the program is run a 2nd time from the button on the worksheet,
lots of errors are generated in the program, as the arrays are full of
data from the first run. If "reset" is clicked in the VB editor, the
arrays empty & the code runs fine. Is there a way to code this
'reset' button & empty the arrays?

Cheers,
Kate



Reply
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
How can I reset the default pie chart label "Other" to "Equity"? russ Charts and Charting in Excel 1 December 3rd 09 08:31 PM
how do i reset the default from "general" to "number" Fog Excel Discussion (Misc queries) 5 February 4th 08 09:34 PM
"Disk is Full" add-on question to "Can't reset last cell" post tod [email protected] Excel Discussion (Misc queries) 0 January 22nd 07 02:32 AM
Pivot Tables - How can I "reset" the selections in "Row Field"? shadestreet Excel Discussion (Misc queries) 3 April 24th 06 06:29 PM
excel.application.run macro1 -- added code to respond "yes" to a inputbox Michael Joe Excel Programming 3 August 13th 04 10:11 PM


All times are GMT +1. The time now is 03:41 AM.

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

About Us

"It's about Microsoft Excel"