+ Reply to Thread
Results 1 to 9 of 9

What are Arrays?

  1. #1
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    What are Arrays?

    Hello

    I have some general questions about Arrays:

    What are Arrays in Excel VBA?
    Are they substitutes of Loops? (What is difference between Arrays & Loops?)
    Please suggest some useful online free resources to learn them.

    Please share some examples where should use them.

    By above questions it will be crystal clear to experts that I really don't know about Arrays.Sorry for that.But really wana know about it because it might be possible that I have been through different occasions where I might be using Arrays but as I don't know about the concept of the same and I had used there a long traditional coding as I am an accountant by profession and I love to automate all of my Excel work through VBA.

    Best Regards
    Imran Bhatti
    Teach me Excel VBA

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: What are Arrays?

    Hi,

    No, arrays are not substitutes for loops.
    An array is, in essence, a way of holding many items/variables within one name. Think of a VBA array as the equivalent of a range of cells in Excel. A Range of cells can be one dimensional, i.e. a single column, or a two dimensional is a range that covers two or more rows and two or more columns.


    In fact it's often the case that an Excel Range is read into a VBA array since it's far quicker to do stuff with a VBA array than with the same details held in an Excel range.

    A Loop is one way of iteratively processing each of the items in an array.

    For more details just google stuff like Excel VBA arrays.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: What are Arrays?

    Array is data structure that contains a group of elements. And is used to store group of variables.
    In VBA, array element (variable) can be accessed by using array name and index number.

    Since index number is sequential, it's used in conjunction with loop to quickly iterate through variables.

    To give an example. You can put range of values from sheet into array.

    Table.JPG

    Please Login or Register  to view this content.
    Above will create two-dimentional array, index starting from 1 (Base 1).

    The array has 5 rows and 3 columns. In array, element in row 2, column 3 can be accessed like below.
    Please Login or Register  to view this content.
    You can find detailed explanation in links below.
    https://www.tutorialspoint.com/vba/vba_arrays.htm
    http://analystcave.com/vba-vba-array/

  4. #4
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: What are Arrays?

    Sir would you mind to please give me an example to play with, in order to get the taste of using arrays? (if it complies with the forum rules)

  5. #5
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: What are Arrays?

    I am gona try it right now.

  6. #6
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: What are Arrays?

    It keeps on printing 80000 in the immediate windows.

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: What are Arrays?

    If you do not know what a loop is you should go back to basic and learn Basic programming. You are trying to drive a car in third gear with out knowing how and why you need to use first gear.
    Richard has given you the core concept of Arrays, but this site is not designed to be a college tutorial.
    Last edited by AB33; 01-06-2017 at 10:31 AM.

  8. #8
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: What are Arrays?

    Thanks AB33

  9. #9
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: What are Arrays?

    Thak you CK your mentioned links are helpfull.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. storing multiple value in a single cell (through arrays or without arrays)?
    By mak51061 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-25-2014, 09:27 PM
  2. Declaring multiple multi-dimensional arrays (jagged arrays) - compile error?
    By dfribush in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-20-2013, 05:06 PM
  3. vba compare arrays and remove exact matching arrays
    By jacojvv in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 10-25-2013, 07:30 AM
  4. [SOLVED] New to arrays-where do I find a good beginners guide to multi dimensional arrays
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-04-2013, 07:44 PM
  5. Sum columns within arrays and then multiplying arrays [?]
    By slickpusher in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-08-2012, 08:50 PM
  6. Help With Arrays, real Basic Arrays
    By Markva in forum Excel General
    Replies: 3
    Last Post: 08-20-2008, 04:11 PM
  7. [SOLVED] Arrays - declaration, adding values to arrays and calculation
    By Maxi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-17-2006, 11:15 AM

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