#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 78
Default Using subtotal

I have data in a column from A2 down to around A800. The data is filtered by
auto filter.

I can get the sum of the visible data with =SUBTOTAL(109,A1:A1000). This
works just fine. Now I want to get the sum of only the last 7 visible
values. Problem is that I dont know how to put in the range because I dont
know it until after the filter is applied.

This is probably very easy, but excel help for subtotal does not cover it.

--
jake
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Using subtotal

Sub sumlastSevenvisible()
mc = 1
On Error Resume Next
For i = Cells(Rows.Count, mc).End(xlUp).row To 1 Step -1
If Rows(i).Hidden = False Then
mycount = mycount + 1
mysum = mysum + Cells(i, mc)
If mycount = 7 Then Exit For
End If
Next i
MsgBox mysum
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Jakobshavn Isbrae" wrote in
message ...
I have data in a column from A2 down to around A800. The data is filtered
by
auto filter.

I can get the sum of the visible data with =SUBTOTAL(109,A1:A1000). This
works just fine. Now I want to get the sum of only the last 7 visible
values. Problem is that I dont know how to put in the range because I
dont
know it until after the filter is applied.

This is probably very easy, but excel help for subtotal does not cover it.

--
jake


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
macro excel subtotal in subtotal GBO Excel Discussion (Misc queries) 2 November 29th 07 02:15 PM
How do I Subtotal, then Sort by Subtotal Amounts? dnamertz Excel Discussion (Misc queries) 3 October 29th 06 12:17 AM
pasting to subtotal lines without replacing hidden -non-subtotal l harleydiva67 Excel Discussion (Misc queries) 1 October 12th 06 06:02 PM
Bolding the subtotal lines automaticlly When using the Subtotal fu 06Speed6 New Users to Excel 2 October 5th 06 03:52 PM
Subtotal of Subtotal displays Grand Total in wrong row Thomas Born Excel Worksheet Functions 5 January 6th 05 01:46 PM


All times are GMT +1. The time now is 10:46 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"