+ Reply to Thread
Results 1 to 7 of 7

Variant Arrays and Ranges of Data

  1. #1
    Forum Contributor
    Join Date
    02-26-2012
    Location
    Ottawa, ON
    MS-Off Ver
    Excel 2007
    Posts
    129

    Variant Arrays and Ranges of Data

    To my understanding, variant arrays are two dimensional. The first dimension for mapping a row and the second for the number of columns. If I set an array equal to range of values that is horizontal, ie:

    Please Login or Register  to view this content.
    Therefor, I think based on my range, that it is mapping only one row, and mapping numberOfColumns-3 columns, correct?

    Later, I'd like to pass this timeArray into a function that makes a plot. The timeArray would be on the x-axis. I had this code working when the range was a column, not horizontally (had to change somethings for work).

    There are three values in this array: 0,100 and 200. When I go to plot it, it only plots 0 and 100. My plotting function is below. My question is, do I need to make a new array in the function for the time?

    Please Login or Register  to view this content.
    Last edited by NatalieEC; 11-06-2014 at 06:08 PM.

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

    Re: Variant Arrays and Ranges of Data

    Arrays populated from a range are 2-dimensional variant arrays, not all variant arrays are 2-dimensional.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    02-26-2012
    Location
    Ottawa, ON
    MS-Off Ver
    Excel 2007
    Posts
    129

    Re: Variant Arrays and Ranges of Data

    Okay, so if I am setting an array with a "horizontal" range, does this mean that only the 2nd dimension has all the different values. I am trying to understand why it is plotting that way.

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

    Re: Variant Arrays and Ranges of Data

    Your array will have the dimensions 1 to 1 by 1 to NumberOfColumns-2.

    All the items in the array will have a value if they have a value in the range.

    I think you might want to change the dimension, ie the 2nd argument of UBound/LBound, you are using in your resize and loop here.
    Please Login or Register  to view this content.
    As it is m will be looping from 1 to 1 and yArray will have the dimensions 0 to 1.

  5. #5
    Forum Contributor
    Join Date
    02-26-2012
    Location
    Ottawa, ON
    MS-Off Ver
    Excel 2007
    Posts
    129

    Re: Variant Arrays and Ranges of Data

    Hi Norie, thanks for your help! I did change the second dimension

    Please Login or Register  to view this content.

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

    Re: Variant Arrays and Ranges of Data

    I don't know why you are using the no of columns to determine which dimension to use.

    There are only 2 dimensions in your array, you should use the 2nd.
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    02-26-2012
    Location
    Ottawa, ON
    MS-Off Ver
    Excel 2007
    Posts
    129

    Re: Variant Arrays and Ranges of Data

    Ohhh, now I think I have a better understanding of variant arrays.

    Thanks so much. I though the second number in the brackets was the number column?

+ 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. [SOLVED] How to use Arrays instead of Ranges
    By Sachy in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-10-2013, 10:54 AM
  2. [SOLVED] Error checking for Variant Arrays?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-13-2013, 05:49 AM
  3. [SOLVED] Type Mismatch when assigning data from ranges (columns) to arrays
    By seigna in forum Excel Programming / VBA / Macros
    Replies: 32
    Last Post: 05-07-2013, 07:40 AM
  4. Conditional rank in VBA, using Variant arrays
    By nchmy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-05-2013, 01:55 PM
  5. [SOLVED] Worksheet names to variant arrays
    By Alasdair Stirling in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-03-2005, 09:05 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