+ Reply to Thread
Results 1 to 12 of 12

Applying a formula to a dynamic range

  1. #1
    Registered User
    Join Date
    07-19-2012
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    13

    Applying a formula to a dynamic range

    Greetings,

    I have created two dynamic ranges, minutes and shift, using the Name manager. For the two ranges, the "refers to" field is as follows
    Please Login or Register  to view this content.
    My question is if I create a new third dynamic range called "result" with the following code..
    Please Login or Register  to view this content.
    ...how can I apply the formula A*B to the entire dynamic range C? That is, for every entry in A and B I want the result of A*B in C, and it needs to be dynamic so that if entries are added to a and b, the results are still reflected in C.

    Thank you so much for the help!

    -Willis

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Applying a formula to a dynamic range

    You may not really need that third dynamic named range. With no context here, I'm guessing at what you're trying to accomplish, but once you have defined two adjacent identical ranges, those names behave in a way you might be able to create the "values" that would have been in the third range without them actually existing at all.


    I created MyNum1 and MyNum2 as ranges with your formulas. Then here's a simple formula that adjusts itself to provide what the value of the third column would be if it existed:

    http://screencast.com/t/fM1ENjRF

    ---------- Post added at 06:48 PM ---------- Previous post was at 06:44 PM ----------

    Ok, I think I see your actual goal now, to have a named range with values in it that don't exist in the sheet. That's doable. All you need are the values in A and B, and your first two named formulas. Then a third named formula that creates an array:

    http://screencast.com/t/jAu5qLng5ZAV


    In this pic you see the third named range formula, and an example in a cell showing how the third value in that array is being pulled out.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    07-19-2012
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Applying a formula to a dynamic range

    Ah thank you. That is exactly what I needed. However, what if I need to compute a more complicated formula on a cell by cell basis, such as
    Please Login or Register  to view this content.
    asuming A is the dynamic range and I is what I want to populate.

    Thanks alot for the help so far.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Applying a formula to a dynamic range

    Why aren't you putting your formulas in cells? A convoluted path is not better than a simple one. Cells are free, extra sheets....no charge.

  5. #5
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2504
    Posts
    13,620

    Re: Applying a formula to a dynamic range

    I wonder why people persist in creating dynamic ranges ( and using volatile functions to define them) when XL2010/2007 provides the Table facility? ( especially in this case)

  6. #6
    Registered User
    Join Date
    07-19-2012
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Applying a formula to a dynamic range

    Well so in the final macro I want the user to just enter column A. Then I would like to autogenerate column I dynamically (so that it is always the same length as the data entered into column A) and apply the formula that I mentioned earlier to that columns.

    So when data is entered into column A and the macro is run, column I should appear and reflect the results of the formula. Hope this makes sense. Thanks!

  7. #7
    Registered User
    Join Date
    07-19-2012
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Applying a formula to a dynamic range

    That was my mistake for opening another thread. Apologies.

    So looking at the other post you made...

    "You have XL2010 ? Then use the Table feature - Named ranges will not be necessary

    First select the range formed by col A and B - Select the Insert Ribbon - Click "Table" and follow the instructions
    Next, in col C add a header if needed - in the cell next to 1st row of data col A and B, enter your formula, it will expand automatically to the last value of col B
    Now when you add or delete values to or from col B, the formula in col C will follow without you having to do anything"

    This works very well, but if my goal is to graph the data, then there will be alot of extra entries that will mess up the data in the graph. That is why I wanted to have ranges.

    For instance, assume I make a table that allows for up to 1000 entries and it has three columns, the third of which is calculated.

    If the user enters 500 entries into column A & B, the the results in column C are A+B, then the second half of column A will be filled with all 0's, messing up the graph.

    This is why I wanted to know how to apply a formula to a dynamic range.

    Thanks,
    Willis

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Applying a formula to a dynamic range

    That's not how tables work. Once you're table is created it typically only has a few rows in it and all the formulas and formatting are applied, then you add more rows to the bottom of the table as needed and all the formatting/formulas add themselves to these added rows. There would be no "500 blank rows" because that's not how you do it.

  9. #9
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Applying a formula to a dynamic range

    mind you why use offset at all?use index
    A2:INDEX($A$2:$A$5000,COUNT(Sheet1!$A$2:$A$5000))
    if its the sum of all a*b then use that with sumproduct
    Last edited by martindwilson; 07-23-2012 at 06:55 PM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  10. #10
    Registered User
    Join Date
    07-19-2012
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Applying a formula to a dynamic range

    Okay that makes perfect sense. Now I have one more quick question. This is all going to be put in a macro that will take the data and graph it. The x-axis is going to be in minutes and hours; so is there an easy for for the user to say i want to graph between 65 and 196 minutes, and then the graph will only display all the data between those two limits? thanks for all the help so far. The table was extremely useful.

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Applying a formula to a dynamic range

    This latest question seems completely unrelated to the thread topic. I would suggest posting a programming question in the Programming forum, possibly with a sample document to illustrate to the helpers what you're trying to achieve.

    It appears this thread topic has been resolved, please select Thread Tools from menu above and set this topic to SOLVED.

  12. #12
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2504
    Posts
    13,620

    Re: Applying a formula to a dynamic range

    Quote Originally Posted by willist View Post
    That was my mistake for opening another thread. Apologies.

    So looking at the other post you made...

    "You have XL2010 ? Then use the Table feature - Named ranges will not be necessary

    First select the range formed by col A and B - Select the Insert Ribbon - Click "Table" and follow the instructions
    Next, in col C add a header if needed - in the cell next to 1st row of data col A and B, enter your formula, it will expand automatically to the last value of col B
    Now when you add or delete values to or from col B, the formula in col C will follow without you having to do anything"

    This works very well, but if my goal is to graph the data, then there will be alot of extra entries that will mess up the data in the graph. That is why I wanted to have ranges.

    For instance, assume I make a table that allows for up to 1000 entries and it has three columns, the third of which is calculated.

    If the user enters 500 entries into column A & B, the the results in column C are A+B, then the second half of column A will be filled with all 0's, messing up the graph.

    This is why I wanted to know how to apply a formula to a dynamic range.

    Thanks,
    Willis
    I suggest you create a simple table with according graph to see how it works, instead of assuming...

+ 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