View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Juan Juan is offline
external usenet poster
 
Posts: 70
Default Macro to open the Subtotal function

Thanks gimme, but that produces an "=sum()" function. What I hope to find is
how to write a macro that would work the same way but instead of doing the
"=sum()" function over the selected range, it would do the "=subtotal(9, )"
function.

I don't know if you're familiar with the difference between these two or
not, so forgive me if I'm telling you something here that you already know:
The "=sum()" function will produce a sum of all the values of all the cells
in the specified range. But the "=subtotal(9, )" function will ignore any
cell in the range that uses the subtotal function and just produce the sum of
the values of the other cells in the range.

So, for example, let cells A1, A2, and A3 have the values 10, 5, and 5. And
let cell A4 have the function "=subtotal(9,A1:A3), then cell A4 will display
"20". Then leave cell A5 blank and let cell A6, A7, and A8 have the values
25, 30, and 20. And let cell A9 have the function "=subtotal(9,A6:A8), so
that cell A9 will display "75". Now skip cell A10, and let cell A11 have the
function "=subtotal(9,A1:A9)", then cell A11 will display "95".

But, if you were to use the "=sum()" function in place of the
"=subtotal(9,)" function in the above example, then cell A11 will display
"190", which would not be the answer I would want if cell A11 was supposed to
be the total of the two previous subtotals.

If you actually did the above example, then you typed the same "=subtotal(9,
)" three times. That's 13 keystrokes times 3, or 39 keystrokes. So what I
need is a macro to quickly set up the "=subtotal(9,) function like the Sigma
button on the toolbar does for the "=sum()" function.

Any ideas? (And thanks again for giving it a shot.)


Juan C.


" wrote:

Did you try selecting the region and clicking the sigma icon (AutoSum)?

The sigma icon looks like this:

-----
\
\
/
/
-----