+ Reply to Thread
Results 1 to 5 of 5

Load data to two-dimensional array

Hybrid View

Mr_Knows_Nothing Load data to two-dimensional... 01-04-2013, 05:57 PM
Norie Re: Load data to... 01-04-2013, 06:01 PM
Mr_Knows_Nothing Re: Load data to... 01-04-2013, 06:05 PM
mike7952 Re: Load data to... 01-04-2013, 06:46 PM
Mr_Knows_Nothing Re: Load data to... 01-04-2013, 06:58 PM
  1. #1
    Registered User
    Join Date
    09-04-2012
    Location
    Denmark
    MS-Off Ver
    Excel 2007
    Posts
    7

    Load data to two-dimensional array

    Hallo.

    How do I load data into a two-dimensional array?

    I'm going to have a (1,1) array, in which I should be able to load a X and Y respectively. (Rows , Columns). Any ideas - it's important it's the variable X and Y there is loaded into the array.

    Thanks

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Load data to two-dimensional array

    What are the exact dimensions of the array and where is the data coming from?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    09-04-2012
    Location
    Denmark
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Load data to two-dimensional array

    Sorry, it's a (1,2) array - one row and two columns.

    The dimension of the array will be (1,2) in which I would like to load data (X,Y). The X and Y will represent the cell reference, e.g. B2 will be (2,2).

    I'll use activecell.row and activecell.column to get the values X and Y.

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Load data to two-dimensional array

    Try this

    Option Explicit
    Sub abc()
     Dim aArr(1 To 1, 1 To 2)
     Dim i As Long
     aArr(1, 1) = "Hello"
     aArr(1, 2) = "World"
     
     For i = 1 To UBound(aArr, 2)
        MsgBox aArr(1, i)
     Next
     
    End Sub
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  5. #5
    Registered User
    Join Date
    09-04-2012
    Location
    Denmark
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Load data to two-dimensional array

    Quote Originally Posted by mike7952 View Post
    Try this

    Option Explicit
    Sub abc()
     Dim aArr(1 To 1, 1 To 2)
     Dim i As Long
     aArr(1, 1) = "Hello"
     aArr(1, 2) = "World"
     
     For i = 1 To UBound(aArr, 2)
        MsgBox aArr(1, i)
     Next
     
    End Sub
    Thank you - it seems to work.

+ 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