+ Reply to Thread
Results 1 to 4 of 4

initialize an array to 0

  1. #1
    Registered User
    Join Date
    12-13-2005
    Posts
    19

    initialize an array to 0

    this should be an easy question for the excel gurus out there...i have an array with size 100 and i want to initialize every value in the array to 0...is there an easy way to do this without running a for loop?

  2. #2
    N10
    Guest

    Re: initialize an array to 0

    try this


    Redim a(100) ' initial declaration of the variable

    your code


    Rem Clear A array

    redim a(100)

    more code

    Best N10


    "kdp145" <[email protected]> wrote in
    message news:[email protected]...
    >
    > this should be an easy question for the excel gurus out there...i have
    > an array with size 100 and i want to initialize every value in the
    > array to 0...is there an easy way to do this without running a for
    > loop?
    >
    >
    > --
    > kdp145
    > ------------------------------------------------------------------------
    > kdp145's Profile:
    > http://www.excelforum.com/member.php...o&userid=29594
    > View this thread: http://www.excelforum.com/showthread...hreadid=521719
    >




  3. #3
    Chip Pearson
    Guest

    Re: initialize an array to 0

    Use the Erase function. If the array is dynamically resized with
    ReDim, you'll have to ReDim it.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com




    "kdp145" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > this should be an easy question for the excel gurus out
    > there...i have
    > an array with size 100 and i want to initialize every value in
    > the
    > array to 0...is there an easy way to do this without running a
    > for
    > loop?
    >
    >
    > --
    > kdp145
    > ------------------------------------------------------------------------
    > kdp145's Profile:
    > http://www.excelforum.com/member.php...o&userid=29594
    > View this thread:
    > http://www.excelforum.com/showthread...hreadid=521719
    >




  4. #4
    Alan Beban
    Guest

    Re: initialize an array to 0

    kdp145 wrote:
    > this should be an easy question for the excel gurus out there...i have
    > an array with size 100 and i want to initialize every value in the
    > array to 0...is there an easy way to do this without running a for
    > loop?
    >
    >


    I don't know what you mean by "i have an array", but any of the
    following will result in an array initialized with zeroes:

    Dim arr(100) As Integer
    Dim arr(100) As Long
    Dim arr(100) As Double

    Alan Beban

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1