+ Reply to Thread
Results 1 to 8 of 8

composing range and using inside formula?

  1. #1
    Registered User
    Join Date
    06-14-2012
    Location
    Italy
    MS-Off Ver
    Excel 16.0
    Posts
    42

    composing range and using inside formula?

    Hi, I'm playing with a table, I'd like to sum values of rows with the 2 most recent dates..where I don't know which is the most recent (table will expand downwards).

    I've tried with INDIRECT in Sheet2 of attached file, but it fails. Can you please help me?

    matrix.jpg

    Thank you!
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,434

    Re: composing range and using inside formula?

    If you turn your table into a real Excel table, then you won't need to know the final row number.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    06-14-2012
    Location
    Italy
    MS-Off Ver
    Excel 16.0
    Posts
    42

    Re: composing range and using inside formula?

    Quote Originally Posted by AliGW View Post
    If you turn your table into a real Excel table, then you won't need to know the final row number.
    uhm..not very expert of this. How would my formula change, then?

    And anyway, I know this might look overcomplicated to you considering the table trick, how could I do it without? I.e. the way I was trying?

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,434

    Re: composing range and using inside formula?

    This is the easy way. Try it.

    1. Select the range B2 to G15.
    2. Insert ribbon - click Table.
    3. Change formula in R7 to this:

    =SUMPRODUCT((Table1[Date]<(LOOKUP(2,1/(Table1[Date]<>""),Table1[Date])+1))*(Table1[Date]>=(LARGE(Table1[Date],COUNTIF(Table1[Date],MAX(Table1[Date]))+1)))*(Table1[[A]:[E]]))

    4. Now add another row with 1104 in the date column and a value somewhere on the row. The formula will adjust its output correctly.
    Attached Files Attached Files
    Last edited by AliGW; 11-06-2017 at 09:29 AM.

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,434

    Re: composing range and using inside formula?

    Let us know how you get on.

  6. #6
    Registered User
    Join Date
    06-14-2012
    Location
    Italy
    MS-Off Ver
    Excel 16.0
    Posts
    42

    Re: composing range and using inside formula?

    AliGW, that's very useful, thank you!

    However, if possible I'd like to solve this using brute force also :P and avoiding the table..then I will call it solved ^^

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,434

    Re: composing range and using inside formula?

    Up to you, of course. I'm sure someone will help. As a matter of interest, what is your reason for wanting to avoid the table? In what way does it or would it cause you problems, other than being new to you?

  8. #8
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: composing range and using inside formula?

    First off, I would HIGHLY recommend that you change your numbers in the Date column into actual dates that Excel recognizes as dates.

    That is, change 1030 to 10/30/2017, 1102 to 11/02/2017, etc.
    Then, you can format these dates however you'd like.

    I agree with Ali that you should make your range into a table if you plan on adding rows to it. If you do not want to do this due to inexperience, I suggest familiarizing yourself with tables rather than looking for another solution. Another solution would be implementing dynamic named ranges (which is more complex than using tables so we won't go there).

    That being said, here is a solution that uses static ranges. You will have to make sure that your data will never exceed the ranges that you put in your formulas.

    =SUMPRODUCT((B3:B100>=LARGE(B3:B100,COUNTIF(B3:B100,MAX(B3:B100))+1))*(C3:G100))

+ 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. Set a range and then use range inside a formula
    By ajm1991 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-18-2016, 06:43 PM
  2. How do you compose an email partly based on data in another workbook?
    By cyberjoad in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-15-2016, 01:44 PM
  3. Composing Date from 3 Inputs
    By lucasar in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-11-2014, 04:19 PM
  4. Expanding Range inside a Formula
    By par0016 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-05-2013, 12:15 PM
  5. [SOLVED] putting $ in the Range which inside .Formula
    By viva2kh in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-18-2012, 04:14 AM
  6. Dynamic range inside array formula with use of match
    By konradz in forum Excel General
    Replies: 2
    Last Post: 06-23-2012, 10:54 AM
  7. Formula disappears inside a named range
    By Jammoca in forum Excel General
    Replies: 8
    Last Post: 12-05-2008, 11:47 PM

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