Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default More efficient way to calculate values


Hi,
I'm trying to make a function that sums values from calls that have th
same outline level. Idea is to calculate only cells until the next uppe
level cell.

Here is what I have done, but this function seems to be ver
unefficient when I'm using that in many cells to calculate quite larg
amount of data.

Do you have any ideas how to make the same more efficient way?


Function OutlineLevelSum(iLevel As Integer, rSumRange As Range)
Dim rCell As Range
Dim vResult

For Each rCell In rSumRange
If Rows(rCell.Row).OutlineLevel = iLevel Then
vResult = vResult + rCell.Value
ElseIf Rows(rCell.Row).OutlineLevel < iLevel Then
Exit For
End If
Next rCell

OutlineLevelSum = vResult
End Functio

--
Mar
-----------------------------------------------------------------------
Marw's Profile: http://www.excelforum.com/member.php...fo&userid=2993
View this thread: http://www.excelforum.com/showthread.php?threadid=49635

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default More efficient way to calculate values

Maybe declaring the function itself as Double helps a bit (Function
OLS(....) as Double)
It avoids one Variant addition per cycle.
I always use Long instead of Integer because that is the basic unit in
32-bit systems. But there may be leftover instructions for Integers, I don't
know. Just try.

--
Kind regards,

Niek Otten

"Marw" wrote in message
...

Hi,
I'm trying to make a function that sums values from calls that have the
same outline level. Idea is to calculate only cells until the next upper
level cell.

Here is what I have done, but this function seems to be very
unefficient when I'm using that in many cells to calculate quite large
amount of data.

Do you have any ideas how to make the same more efficient way?


Function OutlineLevelSum(iLevel As Integer, rSumRange As Range)
Dim rCell As Range
Dim vResult

For Each rCell In rSumRange
If Rows(rCell.Row).OutlineLevel = iLevel Then
vResult = vResult + rCell.Value
ElseIf Rows(rCell.Row).OutlineLevel < iLevel Then
Exit For
End If
Next rCell

OutlineLevelSum = vResult
End Function


--
Marw
------------------------------------------------------------------------
Marw's Profile:
http://www.excelforum.com/member.php...o&userid=29934
View this thread: http://www.excelforum.com/showthread...hreadid=496352



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default More efficient way to calculate values


Thanks for the idea. I did that but it doesn't seem to affect much.


--
Marw
------------------------------------------------------------------------
Marw's Profile: http://www.excelforum.com/member.php...o&userid=29934
View this thread: http://www.excelforum.com/showthread...hreadid=496352

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
calculate values in an unlimited range of cells in a column WITHOUTalso calculating values that had previously been filtered AGAINST? yadang Excel Discussion (Misc queries) 2 October 1st 09 06:18 PM
How can I calculate the R and P values together Jerry W. Lewis Excel Discussion (Misc queries) 0 March 28th 07 01:11 AM
How to calculate values in multiple values with multi conditions Curtis Excel Worksheet Functions 2 July 15th 05 02:36 AM
look up same values in coumn1 and calculate values in 2nd column khan Excel Worksheet Functions 4 June 2nd 05 06:28 PM
More efficient method to copy-paste values in place? quartz[_2_] Excel Programming 4 November 15th 04 01:54 PM


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