Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Shorten multiple sumifs

Hi

Would anyone know of a way to shorten multiple sumifs. This formula
is getting very long.

Sumif(A2,Sheet1!B2:B10,Sheet1!D2:D10)+Sumif(A2,She et1!B2:B10,Sheet1!
F2:F10)+Sumif(A2,Sheet1!B2:B10,Sheet1!G2:G10)etc.

The problem is the design of the sheet where the summed data is not in
adjacent columns. Is there a custom function to shorten this? Thanks
in advance.

Chad
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Shorten multiple sumifs


I made a custom UDF.

=SumifSkip(A2,Sheet1!B2:B10,Sheet1!D2:G10,2)


I took your original formula and change the Sum range to be multiple
columns and added a new parameter which is a number indicating the
number of columns to Skip. If this number was on then it would work
exactly like a regular SumIF.

Here is the code. If calls the reuglar sum If multiple times summing
one column at a time. The only difference between my formula and the
regular Sumif is the compare data (A2) must be a cell Range and not a
String.

Function SumifSkip(Comparedata As Range, _
Comparetarget As Range, Sumtarget As Range, _
ColumnSkip As Long)

Numberofcolumns = Sumtarget.Columns.Count
NumberOfrows = Sumtarget.Rows.Count

ComparedataAddr = Comparedata.Address(external:=True)

ComparetargetAddr = Comparetarget.Address(external:=True)

Set ColumnRange = Sumtarget.Resize(NumberOfrows, 1)

SumifSkip = 0
For Count = 0 To (Numberofcolumns - 1) Step ColumnSkip
ColumnRangeAddr = ColumnRange.Address(external:=True)

SumifSkip = SumifSkip + _
Evaluate("Sumif(" & _
ComparedataAddr & "," & _
ComparetargetAddr & "," & _
ColumnRangeAddr & ")")
Set ColumnRange = ColumnRange.Offset(0, ColumnSkip)
Next Count

End Function


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=183258

Microsoft Office Help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Shorten multiple sumifs

Joel

This is the second time you have helped me in as many days. Thanks so
much. I have not tested it out yet but your prior suggestion worked
really well. Thanks again Joel.

Chad
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Shorten multiple sumifs

Hi Joel

Your code works nicely for one line of the sumed range. For example
if A2 was the summed range and the letter "A" was in A2 then it will
match "A" in Columns B2:B10,D2:D10,F2:F10 etc. But it gives the sum
for the first row nothing moreSo if A wer were in the first row it
would sum B2,D2,F2 etc but if I appeared anywhere else in the range it
would not sum these instances. Is there something I missed?

Thanks

Chad
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
sumifs multiple columns help duketter Excel Worksheet Functions 2 May 8th 10 08:44 AM
using sumifs with multiple criteria? Celia Excel Discussion (Misc queries) 3 April 8th 09 02:14 AM
Multiple Sumifs Emeryville John Excel Worksheet Functions 1 September 19th 08 10:12 PM
SumifS Multiple Sum Ranges dee Excel Worksheet Functions 2 May 23rd 07 08:42 PM
SumifS Multiple Sum Ranges Harlan Grove[_2_] Excel Worksheet Functions 0 May 23rd 07 08:40 PM


All times are GMT +1. The time now is 02:03 AM.

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"