+ Reply to Thread
Results 1 to 3 of 3

Adding Sum to bottom of Col C for all Sheets in Array

  1. #1
    SITCFanTN
    Guest

    Adding Sum to bottom of Col C for all Sheets in Array

    I have 10 sheets that are formatted with the currency in column C. I would
    like to call a sub at the end of a macro to add the sum of col C to each
    sheet in the workbook. My problem is each sheet has a variable number of
    rows so I'm not sure how to say add empty row then add sum at bottom of
    column C. Thank you

  2. #2
    Ardus Petus
    Guest

    Re: Adding Sum to bottom of Col C for all Sheets in Array

    One solution would be to set your totals in column C65536, then hide all
    unused rows.

    HTH
    --
    AP

    "SITCFanTN" <[email protected]> a écrit dans le message de
    news: [email protected]...
    >I have 10 sheets that are formatted with the currency in column C. I would
    > like to call a sub at the end of a macro to add the sum of col C to each
    > sheet in the workbook. My problem is each sheet has a variable number of
    > rows so I'm not sure how to say add empty row then add sum at bottom of
    > column C. Thank you




  3. #3
    Valued Forum Contributor
    Join Date
    12-16-2004
    Location
    Canada, Quebec
    Posts
    363
    Hi

    You could try this code
    Sub loop_worksheets()
    Dim MyArray, MyInt
    sheet_count = ActiveWorkbook.Sheets.Count
    'Changes this for your worksheets
    MyArray = Array("Sheet1", "Sheet2", "Sheet3")
    For j = 0 To sheet_count - 1
    sname = MyArray(j)
    Sheets(sname).Select
    rowcount = Cells(Cells.Rows.Count, "c").End(xlUp).Row
    Range("c" & rowcount + 1).Select
    ActiveCell.FormulaR1C1 = "=SUM(R[-" & rowcount & "]C:R[-1]C)"
    Next
    End Sub

+ 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