+ Reply to Thread
Results 1 to 3 of 3

checking a variable number of cells in a column

  1. #1
    Registered User
    Join Date
    05-29-2013
    Location
    Nebraska, United States
    MS-Off Ver
    Excel 2010
    Posts
    2

    checking a variable number of cells in a column

    I'm trying to write a formula to have one cell add a specific, varying number of cells from a column.

    currently all i've figured out is a long if-then statement similar to the following

    if a1=1;
    then send b1
    else if a1=2
    then send sum(b1:b2)
    else if a1=3
    then send sum(b1:b3)
    and so forth.


    Is there a way to condense this so it's both easier to write and can be extended past the original parameters without going back to extend the code?

    In theory the formula I am looking for would work something like this.

    find the sum of cells b1-b(x) where x is equal to the integer in cell a1
    Last edited by Thatos; 05-29-2013 at 05:42 AM.

  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,724

    Re: checking a variable number of cells in a column

    Try this:

    =SUM(INDIRECT("B1:B"&A1))

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    05-29-2013
    Location
    Nebraska, United States
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: checking a variable number of cells in a column

    Thank you, that works perfectly.

+ 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