+ Reply to Thread
Results 1 to 6 of 6

Creating Array in VBA from a single row and multiple columns

  1. #1
    Registered User
    Join Date
    01-04-2012
    Location
    Perth, WA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Creating Array in VBA from a single row and multiple columns

    Hi all,

    I am hoping someone will be able to help me out. I am using Excel 2010, and have a workbook with a bumber of sheets. What I need to do is create an arrray that spans a number of columns, but all the data is on a single row.

    The data starts at U3 and finishes AC3. The data in each cell is a date. What I want to be able to do is take that data and create an array called Parade_Nights() with each of the dates from each of the cells.

    Hopefully someone will be able to show me how to achieve this

    David
    Last edited by davidWA; 01-08-2012 at 01:21 AM.

  2. #2
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Creating Array in VBA from a single row and multiple columns

    You can assign a range directly to a variant and create an array that way. It will always be a two dimensional array, even if it is just one row or column.

    Please Login or Register  to view this content.
    by way of example.
    Good luck.

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Creating Array in VBA from a single row and multiple columns

    If you would like a 1D array:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    01-04-2012
    Location
    Perth, WA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Creating Array in VBA from a single row and multiple columns

    Thanks for that OnErrorGoto0, if those cell were on a diffenent worksheet how would i define the page that they are on

  5. #5
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Creating Array in VBA from a single row and multiple columns

    You simply need to qualify the range with a worksheet object

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    01-04-2012
    Location
    Perth, WA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Creating Array in VBA from a single row and multiple columns

    Thank you both, OnErrorGoto0 and Kyle123 thats solved the first part of my VBA programming

+ 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