Columns(2)
Columns(2)
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: Columns(2)

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

    I have 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

  2. #2
    Board Regular
    Join Date
    Feb 2002
    Location
    Georgia USA
    Posts
    569
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    why not just use =SUM(A:A),=SUM(B:B),=SUM(C:C)

  3. #3
    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:14, Paul B wrote:
    why not just use =SUM(A:A),=SUM(B:B),=SUM(C:C)
    Hello Paul B,

    Because the columns can vary!

  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

    If you're trying to add some specific columns, try this:

    Sub Test()
    StartCol = 1 'This is Column A
    EndCol = 3 'This is Column C
    FormCol = 4 'This is Column D
    Counter = 0
    For x = StartCol to EndCol
    Counter = Counter + 1
    Cells(Counter, FormCol).Formula = "=SUM(" & Columns(x).Address & ")"
    Next x
    End Sub
    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-20 05:58, Juan Pablo G. wrote:
    If you're trying to add some specific columns, try this:

    Sub Test()
    StartCol = 1 'This is Column A
    EndCol = 3 'This is Column C
    FormCol = 4 'This is Column D
    Counter = 0
    For x = StartCol to EndCol
    Counter = Counter + 1
    Cells(Counter, FormCol).Formula = "=SUM(" & Columns(x).Address & ")"
    Next x
    End Sub
    THANK YOU THANK YOU THANK YOU
    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