+ Reply to Thread
Results 1 to 4 of 4

Syntax for Creating an Integer List

  1. #1
    Registered User
    Join Date
    06-21-2012
    Location
    Tolland, CT
    MS-Off Ver
    Excel 2007
    Posts
    37

    Syntax for Creating an Integer List

    I want to create some kind of ordered list that i can call with the name and a number:

    So if i had

    listnumbers = int1 As Integer, int2 As Integer, int3 As Integer

    If i wanted to call int1 i could just write

    listnumbers(0)

    or something like that. i know how to do this in other languages, but i have no idea what it's called in VBA.

    Any help?

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Syntax for Creating an Integer List

    You need an array, a Variant.

    Please Login or Register  to view this content.

    You can DIM the numbers in the array rather than hardcoding them:

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 06-27-2012 at 10:36 AM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,728

    Re: Syntax for Creating an Integer List

    You can set up an array of, say, 10 integers using this:

    Dim my_list(10) As Integer

    (actually this will give you 11 elements, as element 0 is created automatically). Then you can refer to each element as in other languages, like this:

    my_list(1) = 15
    my_list(5) = 100
    another_variable = my_list(2) * 4

    and so on.

    Hope this helps.

    Pete

  4. #4
    Registered User
    Join Date
    06-21-2012
    Location
    Tolland, CT
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: Syntax for Creating an Integer List

    Awesome thanks guys.

    I completely forgot it was called an array!

+ 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