Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips
 
Posts: n/a
Default sumif only for unhidden rows

As you want manually hidden as well as autofiltered, try this UDF

First add this UDF


Function IsVisible(ByVal Target As Range)
Dim oRow As Range
Dim i As Long
Dim ary()
ReDim ary(1 To 1, 1 To Target.Rows.Count)
i = 0
For Each oRow In Target.Rows
i = i + 1
ary(1, i) = Not oRow.EntireRow.Hidden
Next oRow
IsVisible = ary
End Function


Then use this formula

=SUM(TRANSPOSE(isvisible(C1:C20))*(C1:C20))

which is an array formula, so commit with Ctrl-Shift-Enter.

If the rows are manually hidden, hiding/unhiding does not trigger the UDF,
so you will need to F9.


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"pwz" wrote in message
...
How to build a conditional sum formula for unhidden rows only (other rows
are hidden manually or by auto-filter)? Thanks in advance!

Regards,
Pat




  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default sumif only for unhidden rows

If you're using xl2003, you could use =subtotal(). It was enhanced to be able
to ignore those manually hidden rows, too.

pwz wrote:

How to build a conditional sum formula for unhidden rows only (other rows
are hidden manually or by auto-filter)? Thanks in advance!

Regards,
Pat


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
pwz
 
Posts: n/a
Default sumif only for unhidden rows

How to build a conditional sum formula for unhidden rows only (other rows
are hidden manually or by auto-filter)? Thanks in advance!

Regards,
Pat


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Domenic
 
Posts: n/a
Default sumif only for unhidden rows

Expanding on Dave's contribution and provided you have Excel 2003, since
you're looking for a conditional sum formula, you can use something like
the following formula for filtered data...

=SUMPRODUCT(SUBTOTAL(3,OFFSET(CondRange,ROW(CondRa nge)-MIN(ROW(CondRange)
),0,1)),--(CondRange=Criteria),RangeToSum)

For manually hidden rows, change the 3 to 103.

Hope this helps!

In article , "pwz"
wrote:

How to build a conditional sum formula for unhidden rows only (other rows
are hidden manually or by auto-filter)? Thanks in advance!

Regards,
Pat

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
pwz
 
Posts: n/a
Default sumif only for unhidden rows

Thanks Domenic! It works like a charm!



"Domenic" wrote in message
...
Expanding on Dave's contribution and provided you have Excel 2003, since
you're looking for a conditional sum formula, you can use something like
the following formula for filtered data...

=SUMPRODUCT(SUBTOTAL(3,OFFSET(CondRange,ROW(CondRa nge)-MIN(ROW(CondRange)
),0,1)),--(CondRange=Criteria),RangeToSum)

For manually hidden rows, change the 3 to 103.

Hope this helps!

In article , "pwz"
wrote:

How to build a conditional sum formula for unhidden rows only (other

rows
are hidden manually or by auto-filter)? Thanks in advance!

Regards,
Pat





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
pwz
 
Posts: n/a
Default sumif only for unhidden rows

Thanks to Bob too!


"Bob Phillips" wrote in message
...
As you want manually hidden as well as autofiltered, try this UDF

First add this UDF


Function IsVisible(ByVal Target As Range)
Dim oRow As Range
Dim i As Long
Dim ary()
ReDim ary(1 To 1, 1 To Target.Rows.Count)
i = 0
For Each oRow In Target.Rows
i = i + 1
ary(1, i) = Not oRow.EntireRow.Hidden
Next oRow
IsVisible = ary
End Function


Then use this formula

=SUM(TRANSPOSE(isvisible(C1:C20))*(C1:C20))

which is an array formula, so commit with Ctrl-Shift-Enter.

If the rows are manually hidden, hiding/unhiding does not trigger the UDF,
so you will need to F9.


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"pwz" wrote in message
...
How to build a conditional sum formula for unhidden rows only (other

rows
are hidden manually or by auto-filter)? Thanks in advance!

Regards,
Pat






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
How do you ignore hidden rows in a SUMIF() function? Gerry Excel Worksheet Functions 12 October 8th 09 05:20 PM
How to swap rows and columns? [email protected] Excel Discussion (Misc queries) 5 September 21st 05 08:07 AM
Automatically inserting rows ausdiver99 Excel Worksheet Functions 1 June 2nd 05 02:15 PM
Hiding Rows if the linked rows are blank KG Excel Discussion (Misc queries) 9 May 18th 05 02:32 AM
flexible paste rows function that inserts the right number of rows marika1981 Excel Discussion (Misc queries) 1 February 18th 05 03:40 AM


All times are GMT +1. The time now is 01:03 PM.

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

About Us

"It's about Microsoft Excel"