+ Reply to Thread
Results 1 to 6 of 6

VBA button to sum a column and return

  1. #1
    Registered User
    Join Date
    08-11-2021
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    75

    VBA button to sum a column and return

    I have a table that will of course grow as it is added to. I need a button that will sum column G whether it has 10 rows or 1000. The table itself will be added to multiple times a day for a couple of years. It has headers.

    -Thanks!

  2. #2
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: VBA button to sum a column and return

    Is this what your looking for?

    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: VBA button to sum a column and return

    Or if it's a table, maybe

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    08-11-2021
    Location
    Florida
    MS-Off Ver
    Excel 2019
    Posts
    75

    Re: VBA button to sum a column and return

    Im having a tad of trouble with pointing to that column. Im getting subscript out of range. Please note the button will be on a different page from the table.

    Sub GetTotal()
    With Sheet11.ListObjects("Table1")
    .ShowTotals = True
    .ListColumns("Calculated Rig Charge Difference (lbs)").TotalsCalculation = xlTotalsCalculationSum
    v = .TotalsRowRange(.ListColumns("Calculated Rig Charge Difference (lbs)").Index).Value
    .ShowTotals = False
    MsgBox v
    End With
    End Sub

    Things to note:

    The table is Table1
    I have the code in Sheet11 in vba
    the button is on sheet 1
    the table is on sheet 11 in column 'I' with a header
    I did assign the macro to the button

  5. #5
    Valued Forum Contributor
    Join Date
    09-30-2018
    Location
    Vlaams Brabant Belgium
    MS-Off Ver
    365
    Posts
    456

    Re: VBA button to sum a column and return

    hi,

    you best option is to lower your table and then set a formula above the table in the G column

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    that will always sum all the values whatever amount of rows there are.
    Please be as complete as possible in your asking so it may save use all the time to rework the solution because you didn't give all the requirements. If you have a layout in mind please work it out first so we can adapt our solution to it. Thanks.
    If you have been helped, maybe you could click the *

  6. #6
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: VBA button to sum a column and return

    Im getting subscript out of range
    I'm only getting that if there's a typo in the Sheet name, header or table name.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 11
    Last Post: 09-12-2022, 07:16 AM
  2. Replies: 6
    Last Post: 02-22-2021, 05:27 PM
  3. [SOLVED] Click button to Sort by Alpha, then click button to return Original order
    By ChrisXcel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-29-2020, 10:15 PM
  4. Replies: 3
    Last Post: 11-02-2018, 11:59 AM
  5. Replies: 4
    Last Post: 03-13-2013, 12:38 PM
  6. Macro button - check a column values and return msg box
    By jimjaix in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-18-2009, 04:05 PM
  7. [SOLVED] button to return to top of spreadsheet
    By Cindy B in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-08-2005, 04:06 PM

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