+ Reply to Thread
Results 1 to 7 of 7

Using one dimensional arrays to create a new array and populate column with the new array

  1. #1
    Registered User
    Join Date
    09-18-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Using one dimensional arrays to create a new array and populate column with the new array

    I'm sure this is relatively easy but I have spent a considerable amount of time searching forums and microsoft msdn and cannot figure out how to do this.

    I have two columns in an excel worksheet [a,b] which are both populated with a fixed number of values (some integer, some double). I would like to be able to have a macro that adds A1 + B1, updates column B1 with the new value, and then loops to do the same for each value in the column. I know that I need to store column A in an array and store column B in an array, but I cannot figure out the code to select one value from each array, add them, and store them in a new array.

    So,

    A1+B1 = B1
    A2+B2 = B2
    A3+B3 = B3

    and so on.

    I am working with data from multiple spreadsheets saved on servers so I can not just use the functions in the cells, it has to be done in VBA.

    Thanks.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Using one dimensional arrays to create a new array and populate column with the new ar

    Can't you just do:
    Please Login or Register  to view this content.

  3. #3
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Using one dimensional arrays to create a new array and populate column with the new ar

    If you have real columns of data you may copy column A and then paste special with the Values, Add options over column B.

  4. #4
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Huntsville, AL
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: Using one dimensional arrays to create a new array and populate column with the new ar

    Hi Yudlugar,

    I was testing your code, how would you change it if you had headers?

  5. #5
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Using one dimensional arrays to create a new array and populate column with the new ar

    Please Login or Register  to view this content.

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

    Re: Using one dimensional arrays to create a new array and populate column with the new ar

    Array,code assuming you have sheet1 and no gap in your rows.

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Huntsville, AL
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: Using one dimensional arrays to create a new array and populate column with the new ar

    Oops did not mean to post here
    Last edited by greggpetersen75; 09-25-2013 at 10:10 PM.

+ 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. How to Populate a two dimensional array with text
    By Jim28 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-19-2013, 02:50 PM
  2. [SOLVED] New to arrays-Create two column array with different column order to sheet?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-02-2013, 01:37 AM
  3. Populate a Single Dimensional Array with two Dim Array (matrix)
    By Benjamin1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-03-2011, 12:49 PM
  4. [SOLVED] Populate list box with multi-dimensional array
    By Graham Whitehead in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-10-2006, 07:30 AM
  5. Create One-Dimensional Array from Two-Dimensional Array
    By Stratuser in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2005, 05:06 PM

Tags for this Thread

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