+ Reply to Thread
Results 1 to 12 of 12

One spreadsheet for an array of inputs

  1. #1
    Registered User
    Join Date
    07-12-2017
    Location
    Australia
    MS-Off Ver
    Office 365
    Posts
    8

    One spreadsheet for an array of inputs

    Hi,

    I have an array of variables that is time based (temperature, pressure, %opening etc.). I have a spreadsheet that calculates a result (flow rate) based on these input variables. However, the spreadsheet can only calculate the result based on one set of input variables (for instance, it will calculate the flow based on temperature, pressures etc. at a given time). I want to use the same single spreadsheet to take in sets of variables (one set at a time), calculate the result and paste it against the input variables.

    So, if I have a table of time, temperature, pressure and %valve travel, the spreadsheet would calculate the flow and paste it against each set if inputs. The spreadsheet has lengthy calculations and I don't want to repeat them against each set of inputs. See the attached image.

    Can anyone help me with this please?

    Excel Help.png

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: One spreadsheet for an array of inputs

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    07-12-2017
    Location
    Australia
    MS-Off Ver
    Office 365
    Posts
    8

    Re: One spreadsheet for an array of inputs

    Thanks for the swift reply xladept.

    I have attached a sample Excel file in the manage attachments section (The attachment button here is not working). It has two sheets. One for inputs and output and the other is the spreadsheet. Please have a look and let me know. I am sure it can be automated.

    If you can't access the attachment then please follow the following link.

    https://drive.google.com/file/d/0BxJ...ew?usp=sharing
    Attached Files Attached Files

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: One spreadsheet for an array of inputs

    Well - I've not figured out where to put the variables - it would, I think, be better to just do the calculation in core

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,858

    Re: One spreadsheet for an array of inputs

    A few thoughts:

    1) Probably the "easiest" approach that I see at this point is to make multiple copies of the "Spreadsheet" tab (right click on sheet tab -> move or copy... -> fill out dialog), then adjust the references in each copy of spreadsheet to refer to a different row in "Input&Output". The references in column K of "Input&Output" will need to refer to the appropriate copy of the "Spreadsheet" tab. It will be a little tedious, but it should not take terribly long to make 15 or so copies of "Spreadsheet" and adjust the references.

    2) IMO, one of the fundamental aspects of spreadsheet programming is arranging calculations so that you can take full advantage of "copy and paste". The calculations in "Spreadsheet" is currently arranged in three visually appealing blocks of cells, but this does not make it easy to "copy and paste" to get copies of the same calculation. It will be less visually appealing, but I would recommend that you spend some time with "Spreadsheet" and arrange the calculation(s) so that a complete calculation for a single set of inputs occurs in a single row. If you pay careful attention to relative and absolute references, then it should be a simple "copy and paste" operation to obtain the same calculation for subsequent rows. This is the kind of strategy I use a lot -- Pay attention to how you arrange calculations that you will want to be able to repeat so that it will be easy to copy and paste those calculations.

    Neither of those use VBA. Other ideas that use VBA:
    3) For some frequently used calculations, I like to build a User-Defined Function (UDF) that I can use in the spreadsheet just like any of the built in functions. This requires an investment of time upfront to build and debug the UDF. Once the UDF is programmed, though, it is as simple as entering the UDF (with appropriate attention to arguments and relative and absolute referencing like any other function) into the output cell.

    4) I never use this strategy, but I do see some who will write a VBA macro/Sub procedure that will write the inputs from "Input&Output" into the appropriate cells in "Spreadsheet", allow the calculation to finish, then write the result(s) into the appropriate cell(s) in "Input&Output". I am not fond of this strategy, but some people like it.

    Which of these strategies would you like to use, or do you have another strategy you would prefer to try? Where do you get stuck in implementing that strategy.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: One spreadsheet for an array of inputs

    That can be done with a data table:

    E
    F
    G
    H
    I
    K
    L
    M
    2
    Input to data table
    3
    1
    2.24
    0.60
    40.41
    864.97
    << Selected set of inputs
    4
    Inputs
    5
    Time Stamps Pressure DelP Temperature CV
    6
    BarA kPA C
    22,843
    << prototype formula
    7
    07-Jul-17 00:00:00
    2.24
    0.60
    40.41
    864.97
    1
    22,843
    8
    07-Jul-17 00:05:00
    2.23
    0.55
    40.21
    842.17
    2
    21,592
    9
    07-Jul-17 00:10:00
    2.26
    0.62
    40.03
    694.48
    3
    18,787
    10
    07-Jul-17 00:15:00
    2.22
    0.56
    39.93
    693.59
    4
    18,008
    11
    07-Jul-17 00:20:00
    2.37
    0.49
    39.84
    579.53
    5
    15,081
    12
    07-Jul-17 00:25:00
    2.30
    0.44
    39.75
    616.67
    6
    15,128
    13
    07-Jul-17 00:30:00
    2.22
    0.56
    39.66
    484.07
    7
    12,651
    14
    07-Jul-17 00:35:00
    2.31
    0.45
    39.57
    794.09
    8
    19,562
    15
    07-Jul-17 00:40:00
    2.28
    0.59
    39.47
    857.67
    9
    22,854
    16
    07-Jul-17 00:45:00
    2.36
    0.58
    39.38
    864.95
    10
    23,477
    17
    07-Jul-17 00:50:00
    2.22
    0.52
    39.29
    864.95
    11
    21,742
    18
    07-Jul-17 00:55:00
    2.31
    0.44
    39.20
    864.95
    12
    21,074
    19
    07-Jul-17 01:00:00
    2.30
    0.51
    39.11
    861.17
    13
    21,994
    20
    07-Jul-17 01:05:00
    2.21
    0.53
    39.01
    811.70
    14
    20,502
    21
    07-Jul-17 01:10:00
    2.25
    0.59
    38.92
    802.36
    15
    21,263
    Attached Files Attached Files
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,858

    Re: One spreadsheet for an array of inputs

    Very nice, shg. Easier than anything I had suggested.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: One spreadsheet for an array of inputs

    Gracias, MrS.

  9. #9
    Registered User
    Join Date
    07-12-2017
    Location
    Australia
    MS-Off Ver
    Office 365
    Posts
    8

    Re: One spreadsheet for an array of inputs

    Thank you everyone for the replies.

    @ MrShorty: The spreadsheet only contains some sample values. The number of actual sets of input variables is in hundreds and sometimes thousands (these are time based trends)

    @ shg: Wow. what sorcery is this....? As far as I knew, data tables were limited to 2 input variables only, while you, somehow used it with 4 variables. I will certainly see in depth how you did it, will try to implement it in my work and get back to you guys. Thanks a million everyone.

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: One spreadsheet for an array of inputs

    You're welcome.

  11. #11
    Registered User
    Join Date
    07-12-2017
    Location
    Australia
    MS-Off Ver
    Office 365
    Posts
    8

    Re: One spreadsheet for an array of inputs

    Hey I just managed to decipher what shg did. It's indeed work of a genius! I will briefly mention what was done so that anyone in need of a similar solution may benefit.

    shg actually didn't let the 'data table' function know how many variables are there. The input to the data table was only one, i.e. the index number to the set of inputs. The indexed set of input variables was linked to the spreadsheet input cells. The output in the data table was the formula result. So the data table that the 'data table' function saw was only index numbers vs. results. I guess in this manner, we can have virtually infinite number of inputs managed by the data table.

    Thanks a million!

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: One spreadsheet for an array of inputs

    You're welcome, and thanks for a very clear explanation.

    There's a PDF that I use to refresh myself on data tables in the thread at https://www.excelforum.com/tips-and-...ta-tables.html.

+ 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] loop through array of text inputs
    By TPDave in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-24-2016, 11:39 AM
  2. Creating an array, then looping the inputs
    By TRLWNC in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-16-2015, 03:51 PM
  3. [SOLVED] Lookup and matching help with given user inputs on a spreadsheet
    By rham243 in forum Excel General
    Replies: 2
    Last Post: 08-12-2015, 02:31 PM
  4. Using variable inputs within an array.
    By Doug24 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-05-2014, 04:28 PM
  5. Replies: 4
    Last Post: 01-15-2013, 04:55 PM
  6. How to enter inputs from VBA a interface to excel spreadsheet?
    By Adin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-16-2012, 02:14 PM
  7. Replies: 2
    Last Post: 08-13-2010, 12:15 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