Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 49
Default sumif on a single criteria rows but several sum rows

This sounds simple but is proving tricky

I have row of booleans a1:l1 and want to sum rows below that

a3:l7

according to the booleans value, but how could this be done in 1 cell

sumif wont work because the ranges are different shapes so it only does row 3.

I think the problem is row/column ambiguity

of course you could sub total rows or columns or do multiple sumifs in one
cell, but is there a better way?

Cheers
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,533
Default sumif on a single criteria rows but several sum rows

Hi

This should do it:

=SUMPRODUCT((A1:L1=TRUE)*1,A3:L3,A4:L4,A5:L5,A6:L6 ,A7:L7)

Regards,
Per


"Dazzadata" skrev i meddelelsen
...
This sounds simple but is proving tricky

I have row of booleans a1:l1 and want to sum rows below that

a3:l7

according to the booleans value, but how could this be done in 1 cell

sumif wont work because the ranges are different shapes so it only does
row 3.

I think the problem is row/column ambiguity

of course you could sub total rows or columns or do multiple sumifs in one
cell, but is there a better way?

Cheers


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 49
Default sumif on a single criteria rows but several sum rows

Hi Per

agreed, but it wouldn't work if you wanted to sum 1000 rows, or insert a row

not trying to be an arse just curious....how could you do it using the range
'a3:l7' stated as such?


"Per Jessen" wrote:

Hi

This should do it:

=SUMPRODUCT((A1:L1=TRUE)*1,A3:L3,A4:L4,A5:L5,A6:L6 ,A7:L7)

Regards,
Per


"Dazzadata" skrev i meddelelsen
...
This sounds simple but is proving tricky

I have row of booleans a1:l1 and want to sum rows below that

a3:l7

according to the booleans value, but how could this be done in 1 cell

sumif wont work because the ranges are different shapes so it only does
row 3.

I think the problem is row/column ambiguity

of course you could sub total rows or columns or do multiple sumifs in one
cell, but is there a better way?

Cheers



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,533
Default sumif on a single criteria rows but several sum rows

Hi

OK I see your point, so I created a function to do what you require.

ALT+F11 to open the macro editor Insert Module.
Copy the code below to the code sheet.

To use the function enter =SumBoolean in the desired cell and click on the
equalsign left to the fomula line. Fill in the required values.

Function SumBoolean(BooleanValue As Boolean, BooleanRow As Range, SumRange
As Range) As Double
fRow = SumRange.Cells(1, 1).Row
lRow = SumRange.Rows.Count + fRow - 1

For Each cell In BooleanRow.Cells
If cell.Value = BooleanValue Then
total = total + Application.WorksheetFunction.Sum(Range(Cells(fRow ,
cell.Column), Cells(lRow, cell.Column)))
End If
Next
SumBoolean = total
End Function

Best regards,
Per

"Dazzadata" skrev i meddelelsen
...
Hi Per

agreed, but it wouldn't work if you wanted to sum 1000 rows, or insert a
row

not trying to be an arse just curious....how could you do it using the
range
'a3:l7' stated as such?


"Per Jessen" wrote:

Hi

This should do it:

=SUMPRODUCT((A1:L1=TRUE)*1,A3:L3,A4:L4,A5:L5,A6:L6 ,A7:L7)

Regards,
Per


"Dazzadata" skrev i meddelelsen
...
This sounds simple but is proving tricky

I have row of booleans a1:l1 and want to sum rows below that

a3:l7

according to the booleans value, but how could this be done in 1 cell

sumif wont work because the ranges are different shapes so it only does
row 3.

I think the problem is row/column ambiguity

of course you could sub total rows or columns or do multiple sumifs in
one
cell, but is there a better way?

Cheers




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
Counting characters in multiple rows when rows meet specific criteria news.virginmedia.com Excel Worksheet Functions 3 June 28th 08 09:03 PM
Moving data from multiple rows to single rows Pete Excel Worksheet Functions 5 February 16th 08 01:51 PM
Sum single or duplicate rows with multiple criteria Lisa B Excel Worksheet Functions 3 August 15th 07 08:29 AM
Multi rows to single row jostlund Excel Discussion (Misc queries) 1 January 26th 07 12:17 AM
Multiple rows from a single row [email protected] Excel Discussion (Misc queries) 3 November 20th 06 09:13 PM


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