ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   reloading arrays (https://www.excelbanter.com/excel-programming/294465-reloading-arrays.html)

JJ[_5_]

reloading arrays
 
I can load an array and then it to another sheet. What I
would like to do is clear the array and then re-load it
with different data and write it below the existing data
on another sheet.

How can I clear the array after writing it to the second
sheet?

Thanks

Jim Rech

reloading arrays
 
You can use the Erase statement to clear a static array.

Sub a()
Dim MyArray(0) As String
MyArray(0) = "abc"
MsgBox MyArray(0)
Erase MyArray
MsgBox MyArray(0)
End Sub


--
Jim Rech
Excel MVP
"JJ" wrote in message
...
|I can load an array and then it to another sheet. What I
| would like to do is clear the array and then re-load it
| with different data and write it below the existing data
| on another sheet.
|
| How can I clear the array after writing it to the second
| sheet?
|
| Thanks



Alan Beban[_2_]

reloading arrays
 
To the OP: Although the array "MyArray" has been "cleared" by the
procedure below, it remains declared as a String() type array.

Alan Beban

Jim Rech wrote:
You can use the Erase statement to clear a static array.

Sub a()
Dim MyArray(0) As String
MyArray(0) = "abc"
MsgBox MyArray(0)
Erase MyArray
MsgBox MyArray(0)
End Sub




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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com