Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I created a UDF to perform a regression on two ranges, X and Y that
reliably hangs Excel 2003 and 2007: both ranges are copied into arrays of length N, and I create an array of intermediate results of length N*(N-1)/2 as follows Public Function TheilSenRegression(x As Range, y As Range) Dim xx() As Double, yy() As Double, slopes() As Double 'compute N and Nc2 = N(N-1)/2 ReDim xx(1 to N) as double 'copy x into xx ReDim yy(1 to N) as double 'copy y into yy ReDim slopes(1 to Nc2) as double 'copy intermediate results into slopes .. .. TheilSenSlope = Application.WorksheetFunction.Median(slopes) TheilSenRegression = Array(TheilSenSlope, TheilSenIntercept) End Function The function works like a charm when I call it less than about 10 times in a spreadsheet - X and Y are of length 100, so that nC2 is just under 5000. Call it more often and Excel hangs reliably. My gut instinct is that Excel gets into trouble allocating memory for the array slope() or that calling Median causes a problem, but have no thoughts on how to fix it. Any insights would be greatly appreciated Sincerely Thomas Philips |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel hangs up. | Excel Discussion (Misc queries) | |||
autorecover doesn't work reliably during a forced reboot | Excel Discussion (Misc queries) | |||
Excel Hangs | Excel Discussion (Misc queries) | |||
UserForm Initialize event doesn't fire reliably | Excel Programming | |||
Reliably get sheet 1 of the active workbook | Excel Programming |