+ Reply to Thread
Results 1 to 8 of 8

Using the Changing values of a range to construct a new data array

  1. #1
    Registered User
    Join Date
    07-19-2012
    Location
    Washington DC
    MS-Off Ver
    Excel 2013
    Posts
    36

    Using the Changing values of a range to construct a new data array

    Hello Everyone,

    I asked a herculean question yesterday and get no response. I've made some progress, but I need some help here.


    So if you run the macros while on the 'Example sheet', you'll see the loop. Its coping the rows, placing them into a named range, and another named range executes user-defined calculations. The sheet recalculates every time. The calculations are insignificant and are for example purposes. So each copy and paste, I actually want to be constructing new rows of a two dimensional progress.

    So to my point questions. How do I take these output calculations and put them in a separate array. Right now they are copy and pasting just so you see what all of the information I want to obtain. In the future, the user will define calculations in the cells (not in vba) so unfortunately, I need to go about it this way.

    Please Login or Register  to view this content.


    Anyhelp would be much appreciated. In the upcoming days I will start worrying myself with efficiency because this could be a massive time suck. With the few iterations I have now, its already kind of slow.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Using the Changing values of a range to construct a new data array

    Not sure if I understood the problem, but I've improved the performance and the resulting values after calculation can be stored into a 2D array, you also can collect all calculations by appending current to previous results and checking the array aTmp after all loops:

    Please Login or Register  to view this content.
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

  3. #3
    Registered User
    Join Date
    07-19-2012
    Location
    Washington DC
    MS-Off Ver
    Excel 2013
    Posts
    36

    Re: Using the Changing values of a range to construct a new data array

    I can already see the improvements in the performance. Thanks a ton for that. So its appending but when I test to see the new, appended array it repeats the final output twice, juxtoposed. So if I loop to spit it out gives me an array of 1 x 16 dimensions or if I change how it outputs, 16 x 1.

    An example is below.


    Do I need to change something in the AppendArray2D or in constructing aTmp

    Thank you for the help thus far though!
    Please Login or Register  to view this content.
    I'm uncertain exactly how

  4. #4
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Using the Changing values of a range to construct a new data array

    Hi,

    I inserted both solutions mentioned, If you want to append the results and work with the big array after the loop use:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-19-2012
    Location
    Washington DC
    MS-Off Ver
    Excel 2013
    Posts
    36

    Re: Using the Changing values of a range to construct a new data array

    I think I may have caused some confustion. I have an input arrray and I want to produce an output array. I want that output array to be separate. After, I want to use recreate regurgitate that output array somewhere else. So if I have 144 inputs, I will produce 144 ouputs. (Note: it could be more. I will be referencing a named range that may have different dimensions but for now lets just assume they have the same dimensions.) So the result of two dimensional 18 by 8 array, should be 144 outputs, which is the same dimensions as the inputs (18*8)

    Right now the code produces an array of of 1152 and 1 dimensions. If I attempt to Produce

    Please Login or Register  to view this content.
    I will receive an error because the data array only has one "column" so to speak.

    Please Login or Register  to view this content.
    will produce something, because the new data array is 1152 by 1. This isn't however what I want.


    It seems like there is something that is just off by a bit. I'm not certain what it is though

  6. #6
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Using the Changing values of a range to construct a new data array

    I hope I understood you, you want the same data structure for the output data as the input data, correct?

    Please check this, where the results are written into the 2nd sheet at the end: Array-Copying macros.xlsm

  7. #7
    Registered User
    Join Date
    07-19-2012
    Location
    Washington DC
    MS-Off Ver
    Excel 2013
    Posts
    36

    Re: Using the Changing values of a range to construct a new data array

    That is excellent. For now, the output data needs to be the same dimensions, but its likely that the outputs will be even larger. What part of the code should I modify, if any for that situation? I'm a little hazy on the relationship between the named range 'exoutput', where user-defined calcs will be and AppendArray2D and Get2dArray.

    Thanks in advance for this bit of troubleshooting, you've been an amazing help thus far!

  8. #8
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Using the Changing values of a range to construct a new data array

    Hi,

    currently each value in the table on the starter worksheet produces only one result value, therefor the output has the same dimensions.

    By adding more rows of calculation to the range "exoutput" (e.g. one source value produces two results in two different calculations) the output will have one column more holding that result.
    The code is already prepared for that. See this example where exoutput consist of one row more: Array-Copying macros.xlsm

    Notes:
    1. The range "exoutput" must be a one dimensional list
    2. The range "exoutput" is not re-sized automatically when adding/removing calculations
    3. There cannot be more rows in the output than in the input

+ 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. Array Formula should adjust to changing range
    By Shinga in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-27-2013, 05:38 AM
  2. Excel 2007 : Changing range values in graph
    By Sasidhar in forum Excel General
    Replies: 2
    Last Post: 12-07-2009, 04:46 PM
  3. range values in an array?
    By Mike in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-16-2005, 01:00 PM
  4. Replies: 4
    Last Post: 05-04-2005, 12:06 PM
  5. construct range?
    By Jeff Higgins in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-06-2005, 12:06 AM

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