Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Adding columns using VBA

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

    Default

    I have a spreadsheet which imports a CSV file. I have setup a macro to import and format the CSV correctly. However what I need is to be able to find the first blank cell at the bottom of each column of data and total the entire column. If I use the macro recorder it gives me a fixed range i.e A2:A256. Unfortunately the CSV file differs in size every month and the VBA code should cope with this.

    TIA

    Rex.

  2. #2
    MrExcel MVP Anne Troy's Avatar
    Join Date
    Feb 2002
    Location
    Westwood NJ
    Posts
    2,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Just a little FYI that people don't seem to think of: put your totals at the top.

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

    Default

    This should get you started.

    Sub MySum()
    Range("A65536").End(xlUp).Offset(1).FormulaR1C1 = "SUM(R2C:R[-1]C)"
    End Sub
    Regards,

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

  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-20 07:17, Juan Pablo G. wrote:
    This should get you started.

    Sub MySum()
    Range("A65536").End(xlUp).Offset(1).FormulaR1C1 = "SUM(R2C:R[-1]C)"
    End Sub
    This should read

    Sub MySum()
    Range("A65536").End(xlUp).Offset(1).FormulaR1C1 = "=SUM(R2C:R[-1]C)"
    End Sub

    PLEASE, NO PRIVATE MESSAGES, ANSWER TO THE FORUM.

    _________________
    Regards,

    Juan Pablo G.
    MrExcel.com Consulting

    [ This Message was edited by: Juan Pablo G. on 2002-02-20 08:57 ]

Some videos you may like

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
  •