Prev Previous Post   Next Post Next
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Sumif

Thanks OssieMac, great idea. I will ask you some code related to this in
another post...


"OssieMac" wrote:

Hi yet again Fabian.

I didn't do well at all with this one. The function in column 40 should be

=SumAftZero(A2:AM2,6)

SumAftZero2 was an alternative method I was playing with.

Please accept my apologies for my stuff ups.

--
Regards,

OssieMac


"OssieMac" wrote:

Hi Fabian,

Yet another way is to create a UDF (User Defined Function). This allows you
to insert a function in column 40 and sum the first 6 (or whatever number of
cells you like) after the zeros.

Copy the function into a module and in column 40 (assuming you are summing
the values in row 2) insert the following

=SumAftZero2(A2:AM2,6)

A2:AM2 is the full range of 39 cells and 6 is the number of cells to sum
after the zeros. Drag the formula down.

Function SumAftZero(rngRow As Range, numbToSum As Long)
'Produces circular reference error if less cells
'left to sum than parameter numbToSum
Dim rngC As Range
numbToSum = numbToSum - 1

For Each rngC In rngRow
If rngC.Value 0 Then
Range(rngC, rngC.Offset(0, numbToSum)).Select
SumAftZero = WorksheetFunction.Sum _
(Range(rngC, rngC.Offset(0, numbToSum)))
Exit For
End If
Next rngC

End Function


--
Regards,

OssieMac


 
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
SUMIF Neil Miller Excel Worksheet Functions 2 March 3rd 09 07:20 PM
sumif for multi conditions. i.e sumif(A1:A10,"Jon" and B1:B10,"A" Harry Seymour Excel Worksheet Functions 9 June 12th 07 10:47 PM
Embedding a Sumif in a sumif C.Pflugrath Excel Worksheet Functions 5 August 31st 05 07:31 PM
nested sumif or sumif with two criteria dshigley Excel Worksheet Functions 5 April 5th 05 03:34 AM
SUMIF - Range name to used for the "sum_range" portion of a SUMIF function Oscar Excel Worksheet Functions 2 January 11th 05 11:01 PM


All times are GMT +1. The time now is 07:12 PM.

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

About Us

"It's about Microsoft Excel"