clearing all values of a 2 dimensional array
Upcoming Power Excel Seminars
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: clearing all values of a 2 dimensional array

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Location
    Philadelphia
    Posts
    100
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    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.

  2. #2
    Board Regular
    Join Date
    Mar 2002
    Location
    Cincinnati, Ohio, USA
    Posts
    6,824
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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

  3. #3
    MrExcel MVP Al Chara's Avatar
    Join Date
    Feb 2002
    Location
    Newark, Delaware
    Posts
    1,701
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    How about ReDim.

    ReDim MyArray(1 To 5, 1 To 10)

    Change (1 To 5, 1 To 10) to your dimensions.
    Best regards,
    Allan Chara
    http://www.mrspreadsheets.com

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com