Columns
Power Query Course in Spanish
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 6 of 6

Thread: Columns

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    Hengelo
    Posts
    79
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    Hello,

    I want to total different columns.
    But I can't figure out the right code.

    For b = 1 To 15
    Cells(b, 16).FormulaR1C1 = "=SUM(C & b)"
    Next

    This doesn't work.
    Who can help me!?

    Martin

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Bogota, Colombia
    Posts
    11,959
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-02-19 05:53, MJA wrote:
    Hello,

    I want to total different columns.
    But I can't figure out the right code.

    For b = 1 To 15
    Cells(b, 16).FormulaR1C1 = "=SUM(C & b)"
    Next

    This doesn't work.
    Who can help me!?

    Martin
    Try with

    Cells(b, 16).FormulaR1C1 = "=SUM(C" & b

    But, why use SUM ? that's only one cell, you could just use:

    Cells(b, 16).FormulaR1C1 = "=C" & b
    Regards,

    Juan Pablo González
    http://www.juanpg.com

  3. #3
    New Member
    Join Date
    Feb 2002
    Location
    Belgium
    Posts
    24
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hello Martin,

    Answering you would be easy if you could explain better what you exactly want.

    Do you want to sum the columns from 1 to 15 in the 16th column in row i?
    If yes, check the two codes below:

    For b=1 to 15
    cells(i,16)=cells(i,16)+cells(i,b)
    next b

    OR

    Cells(i, 16).FormulaR1C1 = "=SUM(C1:C15)"

    I hope I could help you,
    Pierre

    [ This Message was edited by: paludgnp on 2002-02-19 06:17 ]

  4. #4
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Bogota, Colombia
    Posts
    11,959
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-02-19 05:59, Juan Pablo G. wrote:

    Try with

    Cells(b, 16).FormulaR1C1 = "=SUM(C" & b

    But, why use SUM ? that's only one cell, you could just use:

    Cells(b, 16).FormulaR1C1 = "=C" & b
    Wait a sec... just spotted an error in my code. Try this instead.

    Cells(b, 16).FormulaR1C1 = "=SUM(C" & b & ")"

    I still don't understand why you need SUM, but this should work.
    Regards,

    Juan Pablo González
    http://www.juanpg.com

  5. #5
    Board Regular
    Join Date
    Feb 2002
    Location
    Hengelo
    Posts
    79
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-02-19 06:00, paludgnp wrote:
    Hello Martin,

    Answering you would be easy if you could explain better what you exactly want.

    Do you want to sum the columns from 1 to 15 in the 16th column in row i?
    If yes, check the two codes below:

    For b=1 to 15
    cells(i,16)=cells(i,16)+cells(i,b)
    next b

    OR

    Cells(i, 16).FormulaR1C1 = "=SUM(C1:C15)"

    I hope I could help you,
    Pierre

    [ This Message was edited by: paludgnp on 2002-02-19 06:17 ]
    Hello again,

    I have say three columns(A, B, C) there is a serie of numbers in each column. I want the total of each column in cells D1, D2 and D3.

    Sub Test()
    For x = 1 To 3
    Cells(x, 4).FormulaR1C1 = "=SUM(C" & x & ")"
    Next
    End Sub

    The macro above can't do the trick.
    WHY?!?!

    Best regards,

    Martin
    Best regards,

    Martin J.A. Maatman Oonk

  6. #6
    Board Regular
    Join Date
    Feb 2002
    Location
    Hengelo
    Posts
    79
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    On 2002-02-20 05:46, Juan Pablo G. wrote:
    Why ? well, because you're only summing column C, not A:C, change it to this:
    Code:
    Sub Test() 
    For x = 1 To 3 
    Cells(x, 4).Formula = "=SUM(A" & x & ":C" & x & ") 
    Next 
    End Sub
    Also, you were mixing two range types, R1C1 with A1 style. This should do the trick.
    C stands for column and then a 1 or 2 or 3 for column A, column B, column C.

    In cell D1 stands the total of column1 = column A

    In cell D2 stands the total of column2 = column B

    In cell D3 stands the total of column3 = column C
    Best regards,

    Martin J.A. Maatman Oonk

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com