+ Reply to Thread
Results 1 to 8 of 8

Insert dynamic column reference into SUMIFS formula?

  1. #1
    Registered User
    Join Date
    04-03-2019
    Location
    Washington
    MS-Off Ver
    MS Office 365
    Posts
    4

    Insert dynamic column reference into SUMIFS formula?

    Hey everyone - I'm trying to create a SUMIFS formula that changes the 'SUM RANGE' column each month automatically based on today's date. The following formula uses the current month to return the column I want, then converts the column number to it's text equivalent (So a date in April returns "D:D")

    =SUBSTITUTE(ADDRESS(1,COLUMN(INDIRECT(ADDRESS(1,MONTH(TODAY())+4))),4),"1","")&":"&SUBSTITUTE(ADDRESS(1,COLUMN(INDIRECT(ADDRESS(1,MONTH(TODAY())+4))),4),"1","")

    I'm trying to plug it into a SUMIFS formula by combining the column reference with the tab name, and inserting it into the SUM RANGE section of the formula, like this:

    =SUMIFS("AccountData!"&=SUBSTITUTE(ADDRESS(1,COLUMN(INDIRECT(ADDRESS(1,MONTH(TODAY())+4))),4),"1","")&":"&SUBSTITUTE(ADDRESS(1,COLUMN(INDIRECT(ADDRESS(1,MONTH(TODAY())+4))),4),"1",""),AccountData!B:B,Account!A5)


    I cant figure out how to attach the tab name to the column reference, and then properly pass it as the SUM RANGE parameter. Any ideas?

    Thanks!
    Last edited by piroshkilla; 04-03-2019 at 07:44 PM.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,721

    Re: Insert dynamic column reference into SUMIFS formula?

    Do you have a header row in row 1? If so, does this contain the text values of the months (i.e. "April", "May", "June"), or the month/year, or are they dates (e.g. the first of the month) which might be formatted to display the month and/or year?

    I can't see your workbook, so I don't know what you have, or how your data is laid out - it would help if you attached a sample Excel workbook.

    To do this, click on Go Advanced (below the Edit Window) while you are composing a reply, then scroll down to and click on Manage Attachments and the Upload window will open. Click on Browse and navigate to (and double-click) the file icon that you want to attach, then click on Upload and then on Close this Window to return to the Edit window. When you have finished composing your post, click on Submit Post.

    Don't try to use the Paperclip icon, as it doesn't work on this forum.

    The short answer is that you can do this using INDEX/MATCH within the SUMIFS function to select the appropriate column, but I will need to see how your data is laid out before I can give you a specific formula.

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    04-03-2019
    Location
    Washington
    MS-Off Ver
    MS Office 365
    Posts
    4

    Re: Insert dynamic column reference into SUMIFS formula?

    Pete_UK - thanks for the response. I tried to upload the file, did it come through? Also, please note I made a change to the formula in the original post. I wasn't returning the column number in the previous one, so I fixed that
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    04-03-2019
    Location
    Washington
    MS-Off Ver
    MS Office 365
    Posts
    4

    Re: Insert dynamic column reference into SUMIFS formula?

    Pete_UK, one more time with an updated sumif formula. Sorry attempted to remove everything unnecessary, ended up ruining the formula in the process.
    Attached Files Attached Files

  5. #5
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,721

    Re: Insert dynamic column reference into SUMIFS formula?

    I'm not sure why you need to use SUMIFS, as column B cells in the Data and AccountData sheets all contain the same thing. This is how you could do it with a straightforward SUM formula:

    =SUM(INDEX(AccountData!$E:$P,0,MATCH(TEXT(TODAY(),"mmm")&"Total",AccountData!$E$1:$P$1,0)))

    so if you wanted to make this a SUMIFS formula, you would need to add the criteria after the sum-range, like this:

    =SUMIFS(INDEX(AccountData!$E:$P,0,MATCH(TEXT(TODAY(),"mmm")&"Total",AccountData!$E$1:$P$1,0)),AccountData!B:B,Account!A5)

    I've just added the criteria that you had in your first post, though it doesn't make sense in your sample workbook.

    Hope this helps.

    Pete

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,721

    Re: Insert dynamic column reference into SUMIFS formula?

    I've just noticed that you reposted a different workbook. Put the formula that I gave above into cell B3 of the Account sheet, and change the A5 to A3 at the end. You don't need B1 or B2.

    Hope this helps.

    Pete

  7. #7
    Registered User
    Join Date
    04-03-2019
    Location
    Washington
    MS-Off Ver
    MS Office 365
    Posts
    4

    Re: Insert dynamic column reference into SUMIFS formula?

    Pete - thanks for the response, this works perfectly. I often catch myself making things more difficult than they need to be, and this was no exception!

  8. #8
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,721

    Re: Insert dynamic column reference into SUMIFS formula?

    Glad it worked for you.

    If that takes care of your original question, please take a moment to select Thread Tools from the menu above and to the right of your first post in this thread, and mark the thread as SOLVED.

    Also, since you are relatively new to the forum, you might like to know that you can directly thank those who have helped you by clicking on the small "star" icon located in the lower left corner of any post that you have found to be helpful (not just in this thread - for any post that has helped you). This also adds to the reputation of the poster (the small green bars in the poster's profile).

    Pete

+ 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. Replies: 11
    Last Post: 12-17-2018, 02:17 PM
  2. [SOLVED] Reference Dynamic Column in Formula Not Using Relative References.
    By Dal123 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 03-11-2017, 12:26 PM
  3. Dynamic Column and SUMIFS
    By rjp82 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-15-2014, 03:47 PM
  4. Using SUMIFS on a variable column reference?
    By tangcla in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-23-2013, 08:15 PM
  5. [SOLVED] Help with sumifs with dynamic sum column selection
    By MCunningham in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 01-14-2013, 03:35 PM
  6. [SOLVED] dynamic column reference, copy formula down
    By intothewild in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-03-2012, 06:19 PM
  7. Insert a formula with relative cell reference based on a number in a column
    By Dcritelli in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-16-2007, 05:54 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