Consulting

Results 1 to 7 of 7

Thread: Solved: SUM a range based on user selection

  1. #1
    VBAX Tutor phendrena's Avatar
    Joined
    Oct 2008
    Location
    Huddersfield, UK
    Posts
    285
    Location

    Solved: SUM a range based on user selection

    Hello all!

    I am having a blank brain moment.

    I've not used excel properly for a few years now and if i don't do anything regularly then I forget it. So I am having a blank moment and would appreciate some pointers.

    I am trying to sum a list of numbers.
    There are 50 numbers in the list (lets say A1:A50)
    Cell B1 is for the user to enter a number from 1-50
    Cell C1 displays the result of the SUM

    Here is the problem - I can't work out how SUM the range based on the users input in cell B1. One user might want to only SUM the first 17 numbers and another user the first 33 numbers.

    So can anyone give me the simple solution that I am looking for.
    Frankly I fell stupid for asking but my ageing brain forgets

    Thanks,

    Dave
    Somewhere in the dark and nasty regions where nobody goes, stands an ancient castle.
    Deep within this dank and uninviting place lives Berk, overworked servant of The Thing Upstairs.
    But thats nothing compared to the horrors that lurk beneath The Trap Door.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Just get them to select the rows to sum and Excel shows the sum in the statusbar at the right.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Tutor phendrena's Avatar
    Joined
    Oct 2008
    Location
    Huddersfield, UK
    Posts
    285
    Location
    Hi xld,

    It's been a loooooooooooong time
    Hope all is well

    I've uploaded the spreadsheet for you to look at.
    It's basically a helper sheet that I'm working on for quick calculations for a dodgy smartphone game that I play! The file itself will be used quite a bit on my smartphone using office mobile so it needs to 'work' based on my input rather than drag and sum etc

    Thanks,

    Dave
    Attached Files Attached Files
    Somewhere in the dark and nasty regions where nobody goes, stands an ancient castle.
    Deep within this dank and uninviting place lives Berk, overworked servant of The Thing Upstairs.
    But thats nothing compared to the horrors that lurk beneath The Trap Door.

  4. #4
    VBAX Newbie
    Joined
    Mar 2005
    Posts
    3
    Location
    Try

    =IF(W9="","",SUM(AD9:INDEX(HomelessGuy,W9)))

  5. #5
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    Whoa... I know its been a big day, but to run into all those colours.

    BTW: There's a guy from the Tax dept.... needs an attitude adjustment, what's it going to take to do this?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  6. #6
    VBAX Tutor phendrena's Avatar
    Joined
    Oct 2008
    Location
    Huddersfield, UK
    Posts
    285
    Location
    Quote Originally Posted by Cutter
    Try

    =IF(W9="","",SUM(AD9:INDEX(HomelessGuy,W9)))
    Cheers! that works quite nicely.
    Now, assuming I wanted to start the SUM further down the range how could I adapt that SUM?

    Thanks,

    Dave
    Somewhere in the dark and nasty regions where nobody goes, stands an ancient castle.
    Deep within this dank and uninviting place lives Berk, overworked servant of The Thing Upstairs.
    But thats nothing compared to the horrors that lurk beneath The Trap Door.

  7. #7
    VBAX Tutor phendrena's Avatar
    Joined
    Oct 2008
    Location
    Huddersfield, UK
    Posts
    285
    Location
    Quote Originally Posted by phendrena
    Cheers! that works quite nicely.
    Now, assuming I wanted to start the SUM further down the range how could I adapt that SUM?

    Thanks,

    Dave
    I'm a fool!

    [VBA]=IF(W9="","",SUM(INDEX(HomelessGuy,AA1):INDEX(HomelessGuy,W9)))[/VBA]

    Sorted
    Somewhere in the dark and nasty regions where nobody goes, stands an ancient castle.
    Deep within this dank and uninviting place lives Berk, overworked servant of The Thing Upstairs.
    But thats nothing compared to the horrors that lurk beneath The Trap Door.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •