clearing all values of a 2 dimensional array

bjr157

Board Regular
Joined
Mar 17, 2002
Messages
100
in VBA how do you reset all the values of a 2 dimensional array back to 0s, i know i could use 2 nested for statements but that takes to long and its a big array that needs to be cleared a lot. is there anyway to do it in one line of code? ive been trying stuff like

clear(MyArray())

i dont have any manuals so any help is appreciated, thanks.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Erase statement

Dim ArrayName(1 to 2, 1 to 2)

to clear it

Erase ArrayName

Look up erase in help.
Different types are treated differently with this statement.
Tom
 
Upvote 0
How about ReDim.

ReDim MyArray(1 To 5, 1 To 10)

Change (1 To 5, 1 To 10) to your dimensions.
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,025
Members
448,939
Latest member
Leon Leenders

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top