+ Reply to Thread
Results 1 to 8 of 8

Automatic select of Total SUM column

Hybrid View

  1. #1
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: Automatic select of Total SUM column

    Hi,

    Does this help you?

    Sub Automate_Sum()
    Dim ws As Worksheet
    Dim iLastColumn As Integer, iLastRow As Integer
    
    For Each ws In ThisWorkbook.Worksheets
    
    With ws
    
    iLastRow = .Range("A" & .Rows.Count).End(xlUp).Row
    iLastColumn = Application.WorksheetFunction.Match("Total SUM", .Rows(1))
    
    .Cells(2, iLastColumn).Formula = "=SUM(C2:" & Cells(2, iLastColumn - 1).Address(0, 0) & ")"
    .Cells(2, iLastColumn).AutoFill Destination:=Range(.Cells(2, iLastColumn), .Cells(iLastRow, iLastColumn))
    
    End With
    
    Next ws
    
    End Sub
    Last edited by sweep; 10-13-2022 at 10:59 AM.
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

+ 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. [SOLVED] Vba makro sort and automatic sum sub total
    By daboho in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-05-2016, 07:05 PM
  2. Select Case Loop to highlight grand total column
    By swade730 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-05-2016, 09:57 AM
  3. [SOLVED] select value less than 50 automatic
    By mazan2010 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-07-2016, 09:37 AM
  4. [SOLVED] Select Automatic Report Filter in Pivot where Filter exist in Data table else select Blank
    By vinaynaran in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-02-2016, 08:47 AM
  5. Automatic total number of weeks
    By khank in forum Excel General
    Replies: 3
    Last Post: 12-31-2010, 12:13 AM
  6. How do I set up an automatic column select
    By Snoopy in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-25-2006, 04:55 AM
  7. [SOLVED] Automatic total of more than one invoices
    By Dr.H.Subramanian in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-24-2005, 05:06 AM

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