Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add total row below dynamic list

I have two worksheets in my file (Excel 2000) that
automatically refresh (from a Microsoft Query) when a
particular cell (input criteria) is changed. I would like
to add a total row at the bottom of both sheets that sums
the data in columns F thru U. The number of rows is
variable based on which criteria is selected for the query
results. Ideally, I would like a blank row and then the
total row at the bottom. I would also like this to be
automatically triggered by the changing of my criteria
cell if that is possible with a macro.

Thanks in advance for any advice.
Laura


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Add total row below dynamic list

Hi Laura,

Try the code below. You will need to change the worksheet
name "Sheet1" to the name of your worksheet. (The code
assumes that there are Titles in Row 1, and the Columns
are hard coded F thru U - so if that changes you will need
to adjust those.)

There may be more efficient ways to do this, but I believe
it will produce the results you want.

Hope this helps.

Regards,
James S

Sub NewTotals()
' This assumes that Row 1 contains Titles and
' should not be included in the SUM formula.
Dim wks As Worksheet
Dim rng As Range
Dim rngColumns As Range
Dim rngLast As Range
Dim i As Integer

Set wks = ThisWorkbook.Worksheets("Sheet1")
Set rngColumns = wks.Range("F2:U2")

For Each rng In rngColumns
Set rngLast = _
Cells(Rows.Count, rng.Column).End(xlUp)
' Offset by one row due to Titles in Row 1.
If rngLast.Offset(1, 0).Address < rng.Address Then
rngLast.Offset(2, 0).Formula = _
"=SUM(" & rng.Address & ":" &
rngLast.Address & ")"
rngLast.Offset(2, 0).Calculate
End If
Next rng
End Sub


-----Original Message-----
I have two worksheets in my file (Excel 2000) that
automatically refresh (from a Microsoft Query) when a
particular cell (input criteria) is changed. I would

like
to add a total row at the bottom of both sheets that sums
the data in columns F thru U. The number of rows is
variable based on which criteria is selected for the

query
results. Ideally, I would like a blank row and then the
total row at the bottom. I would also like this to be
automatically triggered by the changing of my criteria
cell if that is possible with a macro.

Thanks in advance for any advice.
Laura

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic top 20 list Xhawk57 Excel Discussion (Misc queries) 4 November 5th 08 05:41 PM
Dynamic List kevin Excel Worksheet Functions 1 July 16th 07 01:12 PM
lock a total row below a list & allow inserting in the list? Curious Consultant Excel Worksheet Functions 2 May 11th 07 04:14 PM
Data List - Total Row - Only displays "Total" Debbie Long Excel Worksheet Functions 0 February 14th 07 05:52 PM
Changing named Validation list to Dynamic list. GlenC Excel Discussion (Misc queries) 1 July 20th 06 11:49 PM


All times are GMT +1. The time now is 12:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"