Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Controling recalculation - or how to solve my speed problem?

Folks,

I am currently working on a budgeting-sheet. I have personel data on one
worksheed, expected income on another, and want to get an monthly overview
out of this. Since doing this by lookups etc. was difficult or impossible, I
started writing a VBA-function that does work properly and seems simple
enough. When doing that, Excel started becoming slooooww because of frequent
recalculations and this now takes too long. Any idea why this is the case?
Here comes my function (I have two very similar ones ...). Any hints are
appreciated!

Peter

Public Function GehaltSumme(datum, projekt) As Currency
Dim i As Integer
Dim Summe As Currency

Application.Calculation = xlCalculationManual

With Worksheets("Personal")
For i = 1 To .Range("VonSpalte").Rows.Count
If projekt = .Range("ProjektSpalte").Cells(i) Then
If datum = .Range("VonSpalte").Cells(i) Then
If (CLng(.Range("BisSpalte").Cells(i)) = 0) Or (datum <=
..Range("BisSpalte").Cells(i)) Then
Summe = Summe + .Range("BruttoSpalte").Cells(i)
End If
End If
End If
Next
End With
GehaltSumme = Summe

Application.Calculation = xlCalculationAutomatic


End Function


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Controling recalculation - or how to solve my speed problem?

Peter,
Maybe?...
Jim Cone
San Francisco, USA

'----------------
Public Function GehaltSumme(ByRef datum As Double, _
ByRef projekt As Variant) As Double
'Assumes all named ranges are single column ranges.
Dim i As Long
Dim Summe As Double
Dim dblBS As Double
Dim rngVS As Excel.Range
Dim rngPS As Excel.Range
Dim rngBS As Excel.Range

Set rngVS = Worksheets("Personal").Range("VonSpalte").Cells
Set rngPS = Worksheets("Personal").Range("ProjektSpalte").Cell s
Set rngBS = Worksheets("Personal").Range("BruttoSpalte").Cells
Application.Calculation = xlCalculationManual

For i = 1 To rngVS.Count
If projekt = rngPS(i).Value Then
If datum = rngVS(i).Value Then
dblBS = rngBS(i).Value
If (CLng(dblBS) = 0) Or (datum <= dblBS) Then
Summe = Summe + dblBS
End If
End If
End If
Next 'i
GehaltSumme = Summe

Set rngVS = Nothing
Set rngPS = Nothing
Set rngBS = Nothing
Application.Calculation = xlCalculationAutomatic
End Function
'--------------------


"Peter Lipp"
wrote in message
t
Folks,
I am currently working on a budgeting-sheet. I have personel data on one
worksheed, expected income on another, and want to get an monthly overview
out of this. Since doing this by lookups etc. was difficult or impossible, I
started writing a VBA-function that does work properly and seems simple
enough. When doing that, Excel started becoming slooooww because of frequent
recalculations and this now takes too long. Any idea why this is the case?
Here comes my function (I have two very similar ones ...). Any hints are
appreciated!
Peter

Public Function GehaltSumme(datum, projekt) As Currency
Dim i As Integer
Dim Summe As Currency

Application.Calculation = xlCalculationManual
With Worksheets("Personal")
For i = 1 To .Range("VonSpalte").Rows.Count
If projekt = .Range("ProjektSpalte").Cells(i) Then
If datum = .Range("VonSpalte").Cells(i) Then
If (CLng(.Range("BisSpalte").Cells(i)) = 0) Or (datum <=
..Range("BisSpalte").Cells(i)) Then
Summe = Summe + .Range("BruttoSpalte").Cells(i)
End If
End If
End If
Next
End With
GehaltSumme = Summe
Application.Calculation = xlCalculationAutomatic
End Function


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Controling recalculation - or how to solve my speed problem?

Maybe?...
Hmm, yes - it made things somewhat faster, but not as much as I would like
it to be. The major problem currently seems that it calculates too much
anyway, probably there is something else ongoing.

The results of my calculations are in one worksheet, the source in another.
Whenever I switch, it calculates (%age display), but while debugging I
noticed that it did not always call my function (didn't reach my
breakpoints, didn't change the results). Can I control better when it
recaluclates ???
Peter


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Controling recalculation - or how to solve my speed problem?

Peter,

Are the named ranges dynamically sized or are they a
fixed size with unused rows in them?
Charles Williams says it all about Excel calculation...
http://www.decisionmodels.com/optspeedb.htm

Regards,
Jim Cone
San Francisco, USA


"Peter Lipp"
wrote in message

Maybe?...

Hmm, yes - it made things somewhat faster, but not as much as I would like
it to be. The major problem currently seems that it calculates too much
anyway, probably there is something else ongoing.

The results of my calculations are in one worksheet, the source in another.
Whenever I switch, it calculates (%age display), but while debugging I
noticed that it did not always call my function (didn't reach my
breakpoints, didn't change the results). Can I control better when it
recaluclates ???
Peter


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Controling recalculation - or how to solve my speed problem?

Are the named ranges dynamically sized or are they a
fixed size with unused rows in them?

They are fixed (not going through all 65535 of them ;-)

Charles Williams says it all about Excel calculation...
http://www.decisionmodels.com/optspeedb.htm

Interesting. I was now able to turn the autmatic calculation off, which
partially solves my problem - but doesn't answer my question what takes so
long. Probably worth taking a look at C.Ws tool...

Peter



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
Recalculation Problem After Save As. Stuart Hagon Excel Discussion (Misc queries) 4 September 29th 08 11:48 AM
Improving Recalculation Speed for Complex Links Andrew Excel Discussion (Misc queries) 0 November 7th 06 09:29 AM
Problem when multipple users access shared xl-file at the same time, macrocode for solve this problem? OCI Excel Programming 0 May 16th 04 10:40 PM
Recalculation Speed After Editing Macro Code Bob Keating Excel Programming 1 November 16th 03 01:08 PM
Formula recalculation speed Steve Slack Excel Programming 3 October 1st 03 06:06 AM


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

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"