+ Reply to Thread
Results 1 to 6 of 6

adding variable number of columns

  1. #1
    confused
    Guest

    adding variable number of columns

    Hi,

    Can you add a variable number of columns?
    I have a value in cell A1 which can be a number between 1 and 12.
    In cell B1 I want a formula which will give:
    If A1 = 1, B1 = A2
    If A1 = 2, B1 = A2+B2
    If A1 = 3, B1 = A2+B2+C2
    If A1 = 4, B1 = A2+B2+C2+D2...etc
    is there a way to say B2 = A2 plus n cells in the same row, where n is the
    vvalue in cell A1?

    thanks for any help you can give!
    cheers

  2. #2
    Jay
    Guest

    Re: adding variable number of columns

    > Can you add a variable number of columns?
    > I have a value in cell A1 which can be a number between 1 and 12.
    > In cell B1 I want a formula which will give:
    > If A1 = 1, B1 = A2
    > If A1 = 2, B1 = A2+B2
    > If A1 = 3, B1 = A2+B2+C2
    > If A1 = 4, B1 = A2+B2+C2+D2...etc
    > is there a way to say B2 = A2 plus n cells in the same row, where n is
    > the value in cell A1?



    One way:
    =SUM(A2:INDIRECT(CHAR(CODE("A")+A1)&2))

  3. #3
    Duke Carey
    Guest

    RE: adding variable number of columns

    =sum(offset(A2,0,0,1,b1))

    "confused" wrote:

    > Hi,
    >
    > Can you add a variable number of columns?
    > I have a value in cell A1 which can be a number between 1 and 12.
    > In cell B1 I want a formula which will give:
    > If A1 = 1, B1 = A2
    > If A1 = 2, B1 = A2+B2
    > If A1 = 3, B1 = A2+B2+C2
    > If A1 = 4, B1 = A2+B2+C2+D2...etc
    > is there a way to say B2 = A2 plus n cells in the same row, where n is the
    > vvalue in cell A1?
    >
    > thanks for any help you can give!
    > cheers


  4. #4
    Duke Carey
    Guest

    RE: adding variable number of columns

    sorry about that. wrong cell reference

    =SUM(OFFSET(A2,0,0,1,A1))

    "confused" wrote:

    > Hi,
    >
    > Can you add a variable number of columns?
    > I have a value in cell A1 which can be a number between 1 and 12.
    > In cell B1 I want a formula which will give:
    > If A1 = 1, B1 = A2
    > If A1 = 2, B1 = A2+B2
    > If A1 = 3, B1 = A2+B2+C2
    > If A1 = 4, B1 = A2+B2+C2+D2...etc
    > is there a way to say B2 = A2 plus n cells in the same row, where n is the
    > vvalue in cell A1?
    >
    > thanks for any help you can give!
    > cheers




  5. #5
    Myrna Larson
    Guest

    Re: adding variable number of columns


    =SUM(OFFSET($A$2,0,0,1,A1))


    On Thu, 22 Sep 2005 10:16:02 -0700, "confused"
    <[email protected]> wrote:

    >Hi,
    >
    >Can you add a variable number of columns?
    >I have a value in cell A1 which can be a number between 1 and 12.
    >In cell B1 I want a formula which will give:
    >If A1 = 1, B1 = A2
    >If A1 = 2, B1 = A2+B2
    >If A1 = 3, B1 = A2+B2+C2
    >If A1 = 4, B1 = A2+B2+C2+D2...etc
    >is there a way to say B2 = A2 plus n cells in the same row, where n is the
    >vvalue in cell A1?
    >
    >thanks for any help you can give!
    >cheers


  6. #6
    confused
    Guest

    RE: adding variable number of columns

    thanks everyone!!

    "confused" wrote:

    > Hi,
    >
    > Can you add a variable number of columns?
    > I have a value in cell A1 which can be a number between 1 and 12.
    > In cell B1 I want a formula which will give:
    > If A1 = 1, B1 = A2
    > If A1 = 2, B1 = A2+B2
    > If A1 = 3, B1 = A2+B2+C2
    > If A1 = 4, B1 = A2+B2+C2+D2...etc
    > is there a way to say B2 = A2 plus n cells in the same row, where n is the
    > vvalue in cell A1?
    >
    > thanks for any help you can give!
    > cheers


+ 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