View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Excel 2000 to Excell 97 Vba Problem

That is true only if the rows are visible or hidden as a result of a filter.
If that is the case, the Worksheetfunction.Subtotal(9,Range) would get the
sum of the visible cells. If they have been hidden using code or manually,
then subtotal would not work.

in either case
Dim rng as Range, rng1 as Range
set rng = Range("B9:B35")
set rng1 = rng.Specialcells(xlVisible)
msgbox worksheetFunction.Sum(rng1)

would sum just the visible cells.

--
Regards,
Tom Ogilvy



Kieran wrote in message
...
James,


use application.worksheetfunction.subtotal(9, range).

Subtotal has many subfucntions (as the 9 parameter) suggests, but all
the functions only operate on visible rows.


---
Message posted from http://www.ExcelForum.com/