LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Law Law is offline
external usenet poster
 
Posts: 9
Default Can you improve the performance on my user defined function?

Hi All

I have 5 sheets. 4 of the sheets contain forecast data and 1 of them
contains Actual data.

The forecast sheets have the following formula under the required
columns at the bottom of the data range for calculating the
corresponding actual total when the forecast data is autofiltered:

'=SUM((SpecialLookUp(SubRangeSingleCol(QT_SAM_FCT4 _1, 3), ACT!
QT_SAM_ACT_1, 3, 6)))

Essentially what I am doing here is retrieving the filtered row IDs in
the Forecast sheet and then looking up these rowIds in the Actual data
sheet and then summing these req. values of the Actual data in the
Forecast sheet.

The problem occurs when I filter the Actual data it takes ages for
Excel to re-calculate these lookup formulas in the Forecast sheets.

Any suggestion as to how to make the calculation quicker would be more
than welcome.




Function SubRangeSingleCol(QueryRange As Range, Col As Integer) As
Range

For Each cl In QueryRange.Columns(Col).Cells

If (cl.EntireRow.Hidden = False) Then
If SubRangeSingleCol Is Nothing Then
Set SubRangeSingleCol = cl
Else
Set SubRangeSingleCol = Union(SubRangeSingleCol, cl)
End If
End If

Next cl


End Function

Function SpecialLookUp(IDInputRange As Range, LookUpRange As Range,
IDCol As Integer, ResultCol As Integer) As Range

For Each cl In IDInputRange.Cells
For Each cl1 In LookUpRange.Columns(IDCol).Cells
If SpecialLookUp Is Nothing Then
If cl1.Value = cl.Value Then
Set SpecialLookUp = cl1.Offset(0, ResultCol)
End If
Else
If cl1.Value = cl.Value Then
Set SpecialLookUp = Union(SpecialLookUp,
cl1.Offset(0, ResultCol - IDCol))
End If
End If
Next cl1

Next cl

End Function


Regards

Lars

 
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
Improve the performance of Excel 2007. Heera Excel Worksheet Functions 1 October 23rd 08 03:14 AM
Help Optimizing a Sheet to improve performance Vulcan Excel Worksheet Functions 2 June 14th 08 02:56 AM
Trying to improve the performance of my code Carlo Excel Programming 2 December 22nd 06 09:06 AM
PageBreak problem. How to improve performance? [email protected] Excel Programming 2 September 23rd 05 01:55 AM
Advanced Filters - improve performance ? IrelandA Excel Programming 1 August 26th 03 05:41 PM


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