+ Reply to Thread
Results 1 to 24 of 24

Sum variable range

  1. #1
    Registered User
    Join Date
    11-28-2012
    Location
    United Kingdom
    MS-Off Ver
    Professional Plus 2016
    Posts
    29

    Sum variable range

    Hi, I'm looking for a way to SUM data from a range of cells in the column above.
    However, I want to only sum cells from part of the column.
    e.g.
    SUMIF(A3:A5,H1=5) ..... but SUMIF(A2:A5,H1=6)
    In other words, if I change H1 for the numbers 1-6 (Years in Primary school) can I sum different cells in the A column

    I tried attaching the workbook with a different computer - still no joy. The attachment button is there, but simply won't allow me to attach anything!
    Last edited by jjmmoo; 09-20-2017 at 02:48 AM. Reason: Attachment

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Sumifs

    maybe try using SUM and OFFSET?
    =SUM(OFFSET(A3,,,H1,1))
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    11-28-2012
    Location
    United Kingdom
    MS-Off Ver
    Professional Plus 2016
    Posts
    29

    Re: Sum variable range

    I can't seem to get that to work! Any other suggestions?

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Sum variable range

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. 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 demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Sum variable range

    I changed H1 to C3, to keep my sample small...
    A
    B
    C
    3
    1
    15
    5
    4
    2
    5
    3
    6
    4
    7
    5
    8
    6
    9
    7

    B3=SUM(OFFSET(A3,,,C3,1))
    Note the 3 commas in there

    What was not working for you? Wrong answer? no answer?, something else?

  6. #6
    Registered User
    Join Date
    11-28-2012
    Location
    United Kingdom
    MS-Off Ver
    Professional Plus 2016
    Posts
    29

    Re: Sum variable range

    I can't seem to attach my workbook, each time I press the 'attach file' button nothing happens!

    I can't even attach a picture!

    I'll try to explain again:

    I have a workbook which is adding up the different levels of children in a class.
    The levels go
    1c, 1b, 1a, 2c, 2b, 2a etc. to 6a. (They run down the A column)
    I then have the number of pupils on each level in the B column, e.g. 5 on 2c, 10 on 2b etc.

    This data is being taken from a larger spreadsheet which has the data of the pupils in the school.

    I want to add up the amount of pupils who are on target, In year 5 that means they need to be above 3b. So, when H1 says "5", I need the spreadsheet to add up all the levels from 3b-6a.
    When H1 is changed to say "6", I want it to add up all the cells from 4c-6a (because the year 6 target is higher than the year 5 target.)

    I'm sorry for not being able to attach, I'd really appreciate the help with this.

  7. #7
    Registered User
    Join Date
    11-28-2012
    Location
    United Kingdom
    MS-Off Ver
    Professional Plus 2016
    Posts
    29

    Re: Sum variable range

    Hi - I can make that work, but when I change H1 to "6", I can't seem to make the offset change
    When your C3 is 5 what adds up? If you change C3 to 6 what changes?

  8. #8
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Sum variable range


    To attach an Excel file to your post,
    • click Go Advanced,
    • scroll down until you see Manage Attachments,
    • click that and select Browse,
    • select your file and click Open,
    • click Upload and you will see your attachment below Upload Files from a website
    • click Close this window,
    • click Submit reply

    After that you should see attachment in your post

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Sum variable range

    Quote Originally Posted by jjmmoo View Post
    Hi - I can make that work, but when I change H1 to "6", I can't seem to make the offset change
    When your C3 is 5 what adds up? If you change C3 to 6 what changes?
    When C3 = 5, the answer is 15 (1+2+3+4+5)
    When I change C3 to 6, the answer is 21 (1+2+3+4+5+6)
    A
    B
    C
    3
    1
    21
    6
    4
    2
    5
    3
    6
    4
    7
    5
    8
    6
    9
    7


    Do you by chance have calcs set to manual?

  10. #10
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,935

    Re: Sum variable range

    Quote Originally Posted by jjmmoo View Post
    I want to add up the amount of pupils who are on target, In year 5 that means they need to be above 3b. So, when H1 says "5", I need the spreadsheet to add up all the levels from 3b-6a.
    When H1 is changed to say "6", I want it to add up all the cells from 4c-6a (because the year 6 target is higher than the year 5 target.)

    .
    If We target 5 year then how you will say it should be 3B-6a, can you please explain the logic behind it and second you said if you will put H1=6 the cells from 4c-6a...?

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    If I helped, Don't forget to add reputation (click on the little star ★ at bottom of this post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  11. #11
    Registered User
    Join Date
    11-28-2012
    Location
    United Kingdom
    MS-Off Ver
    Professional Plus 2016
    Posts
    29

    Re: Sum variable range

    The attachment should be on now - thanks.
    Attached Files Attached Files

  12. #12
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,935

    Re: Sum variable range

    Jjmmo can you please let us know how are you placing conditional formatting I mean how the numbers are starting and ending ? For dynamic formula you must clear the concept of these numbers .

  13. #13
    Registered User
    Join Date
    11-28-2012
    Location
    United Kingdom
    MS-Off Ver
    Professional Plus 2016
    Posts
    29

    Re: Sum variable range

    I don't really understand what you mean.
    The numbers in the cells are just random on the workbook attached.
    On the real workbook, the numbers come through from a sheet where the teachers have 'levelled' the children in different subjects. This sheet is then counting how many children are on level 3c etc.

  14. #14
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,935

    Re: Sum variable range

    How did you make conditional formatting what is reason for making it???

  15. #15
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,609

    Re: Sum variable range

    ....The numbers in the cells are just random on the workbook attached. On the real workbook...

    You will get better, more accurate help when your sample data is more realistic. However, use the CHOOSE function to choose the sum range, thus:

    blue;
    Please Login or Register  to view this content.
    Note that you only provided ranges for years 5 and 6.

    CF (blue):
    Please Login or Register  to view this content.
    over range: $A$6:$K$21
    Attached Files Attached Files
    Last edited by protonLeah; 09-20-2017 at 03:32 PM. Reason: attachment
    Ben Van Johnson

  16. #16
    Registered User
    Join Date
    11-28-2012
    Location
    United Kingdom
    MS-Off Ver
    Professional Plus 2016
    Posts
    29

    Re: Sum variable range

    You're onto it I'm sure!

    I've reattached. Hopefully you can see that I'm picking up data from one worksheet, but on this analysis page I want to be able to simply change the year group to see how many pupils in each year group are on a particular level.
    Attached Files Attached Files

  17. #17
    Registered User
    Join Date
    11-28-2012
    Location
    United Kingdom
    MS-Off Ver
    Professional Plus 2016
    Posts
    29

    Re: Sum variable range

    Please can you try to explain the (SUM(CHOOSE... formula, I am struggling to understand it. If I could understand it, I'd have a go myself

  18. #18
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,935

    Re: Sum variable range

    More dynamic try

    B22
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Copy across.

  19. #19
    Registered User
    Join Date
    11-28-2012
    Location
    United Kingdom
    MS-Off Ver
    Professional Plus 2016
    Posts
    29

    Re: Sum variable range

    Still don't understand. Please can you download the workbook and then reattach?

  20. #20
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,935

    Re: Sum variable range

    Ok check the attached file
    Attached Files Attached Files

  21. #21
    Registered User
    Join Date
    11-28-2012
    Location
    United Kingdom
    MS-Off Ver
    Professional Plus 2016
    Posts
    29

    Re: Sum variable range

    Do I need to keep the conditional formatting in place for this to keep working?

    I'd like to change the conditional formats to match the cells highlighted on the right hand side of the spreadsheet (05:Q13)

  22. #22
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,935

    Re: Sum variable range

    No, there is no need for conditional formatting for working the formula.

    Second if you want to make conditional formatting use =$O6=$H$1 formula in condition formatting rule by selecting the O6:Q13 range.

  23. #23
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,609

    Re: Sum variable range

    For the formula:
    =SUM(CHOOSE(H1,,,,,B17:B21,B19,B21))
    You have number in H1: 1 - 6, that will be used as the INDEX number for the Choose function.

    Following the index number are a list of values to be selected by the index number. Since, in your original example, you only had 5 & 6, I put the sum ranges for fifth and sixth grades in the fifth and sixth value positions (notice the commas because there are no values for the first 4 positions). So that either B17:B21 or B19:B21 is returned to the Sum function (i.e., SUM(B17:B21) or SUM(B19:B21).
    Last edited by protonLeah; 09-21-2017 at 04:24 PM.

  24. #24
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,609

    Re: Sum variable range

    Try:
    Expected (green)
    Please Login or Register  to view this content.
    +1 Level (blue):
    Please Login or Register  to view this content.
    For conditional format, maybe:
    level 1:
    Please Login or Register  to view this content.
    Expected:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by protonLeah; 09-21-2017 at 04:23 PM.

+ 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: 0
    Last Post: 08-22-2017, 03:49 PM
  2. [SOLVED] Sumifs formula without using sumifs....
    By blockbyblock in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-10-2017, 10:45 AM
  3. [SOLVED] If no SUMIFS matches, 1, otherwise the SUMIFS result...
    By JYTS in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-04-2016, 07:39 PM
  4. sumifs vs. Application.WorksheetFunction.SumIfs
    By flooyd in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-01-2016, 11:22 AM
  5. [SOLVED] Looking for something simpler than SUMIFS - SUMIFS
    By YAbdelaal in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-27-2014, 10:38 AM
  6. SUMIFS Puzzle - Trying to avoid adding multiple SUMIFS to get valid result
    By haldavid in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-09-2013, 03:42 PM
  7. [SOLVED] Sumifs, problem with the formula: =sumifs(c10:c200,<=today(),0)
    By Faustocruz in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-08-2012, 04:26 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