Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Lag functions or faster code

I have a large spreadsheet (several sheets with hundreds
of equations) that is used for economic modeling and
simulation. I use global range names to refer to
chronological data arranged in rows. The names make
formulas more readable for analysis and debugging. Several
equations required lagged values (data from previous time
periods located in columns to the left of the calling
cell), so I wrote a VB macro function to select the
appropriate lagged data. Unfortunately, it appears that
the macro is slowing the calculation process substantially.

Is there a built in Excel function that will perform the
task more quickly. If not, does anyone have suggestions
for improving the macro to speed up the calculation. The
function is listed below.

Thanks in advance.

Function Lag(ByVal strVName As String, lngNLags As Long)
As Variant

Dim lngCol As Long 'Holds column of calling
cell
Dim lngRow As Long 'Holds row of named range
Dim strSheetName As String 'Holds sheet name of the
named range
Dim lngCut As Long 'Used to trim reference
string

lngCol = Application.Caller.Column -
lngNLags 'Set column
lngRow = ActiveWorkbook.Names
(strVName).RefersToRange.Row

'Isolate named range's sheet name
strSheetName = ActiveWorkbook.Names
(strVName).RefersTo 'Get reference
lngCut = Len(strSheetName) - 1
strSheetName = Right(strSheetName,
lngCut) 'Remove = sign
lngCut = InStr(strSheetName, "!") - 1
strSheetName = Left(strSheetName,
lngCut) 'Remove cell reference
strSheetName = Replace
(strSheetName, "'", "") 'Remove single quotes

Lag = ActiveWorkbook.Worksheets(strSheetName).Cells
(lngRow, lngCol).Value
End Function


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Lag functions or faster code

Frank Fuller -

Is there a built in Excel function that will perform the task more

quickly. <

OFFSET

- Mike Middleton, www.usfca.edu/~middleton


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
How to convert cell formula functions to code functions Adnan Excel Discussion (Misc queries) 1 October 1st 08 08:30 PM
Can faster CPU+larger/faster RAM significantly speed up recalulati jmk_li Excel Discussion (Misc queries) 2 September 28th 05 10:24 AM
Where can I see VBA code for financial functions? eios Excel Worksheet Functions 1 November 2nd 04 01:00 PM
Could this code be faster? ste mac Excel Programming 2 August 27th 03 12:59 PM
Using Built in Functions in VBA Code Chris Parker Excel Programming 1 July 16th 03 05:42 PM


All times are GMT +1. The time now is 01:32 PM.

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

About Us

"It's about Microsoft Excel"