old amounts in an array run more than once

N

Niels

I have created a complex macro in word reading through a standardised document.

All amounts are picked up in an array called NBs(40,10) through a select
case.

If I start the macro once again - even with another document - the old
amounts are still in the NBs() array.

I then tried a sub to clean up the array. That did even not work.

So I have top close Word completely to avoid old figures?

I have run the macro in word 2000 2003 and now in 2007 with the same bad
result.

Are there anybody who knows a way around this fault?

kind regards

Niels
 
O

old man

Hi,

Its unclear where your array is declared (at the procedure or modular leval
and how) - so please post some code.

To clear out an array you can do this:

Dim a1() as integer
ReDim a1(200)
a1(1) = 50

ReDim a1(200)

This creates a dynamic array. When it is 'redimed' all the previous values
are lost. In this case I used the same length.

To preserve the values use this:

ReDim preserve a1(200)

you can also redim to another length:

redim a1(25)

with, or without, preserve.

old man
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top