ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Getting the sum from filtering (https://www.excelbanter.com/excel-programming/425848-getting-sum-filtering.html)

Jason V[_2_]

Getting the sum from filtering
 
I am trying to filter on a column and then I want to sum the result of the
visible rows. How do I fo this in code?

Thanks
--
Jason V

ryguy7272

Getting the sum from filtering
 
Great Question! Use Subtotal!!
Function Solution:
http://www.contextures.com/xlFunctions01.html#Filter

VBA Solution:
http://www.mrexcel.com/archive/VBA/5209.html
http://www.ozgrid.com/News/excel-subtotal-dynamic.htm

HTH,
Ryan---

"Jason V" wrote:

I am trying to filter on a column and then I want to sum the result of the
visible rows. How do I fo this in code?

Thanks
--
Jason V


Mike H[_6_]

Getting the sum from filtering
 
try

MyTot = WorksheetFunction.Subtotal(109, Range("A2:A8"))

Mike

"Jason V" wrote in message
...
I am trying to filter on a column and then I want to sum the result of the
visible rows. How do I fo this in code?

Thanks
--
Jason V




Mike H[_6_]

Getting the sum from filtering
 
I should have added wher A2 :A8 is the unfiltered range

Mike
"Mike H" wrote in message
...
try

MyTot = WorksheetFunction.Subtotal(109, Range("A2:A8"))

Mike

"Jason V" wrote in message
...
I am trying to filter on a column and then I want to sum the result of the
visible rows. How do I fo this in code?

Thanks
--
Jason V






Jason V[_2_]

Getting the sum from filtering
 
I am still having trouble. Here is a sample spreadsheet

Green 2
Green 2
Blue 3
Red 4
Green 3

I want to filter on green and then sum the values (7) and then assign the
sum to a variable. I do not know the unfiltered range because it will
continue to grow. Do I select the whole column then?

Thanks
Jason V


"Mike H" wrote:

I should have added wher A2 :A8 is the unfiltered range

Mike
"Mike H" wrote in message
...
try

MyTot = WorksheetFunction.Subtotal(109, Range("A2:A8"))

Mike

"Jason V" wrote in message
...
I am trying to filter on a column and then I want to sum the result of the
visible rows. How do I fo this in code?

Thanks
--
Jason V








All times are GMT +1. The time now is 07:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com