Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a function that I need to run very frequently for an end user
application that is already slow enough. What I need to do is to add up the values in every second column to the right of a given cell. I was hoping that someone could look at this code and tell me if there is any way to squeek a little more speed out of it... Option Explicit Sub test() Dim x As Double x = AddAlternatingColumns(Sheet2, Sheet2.Range("B2")) MsgBox x End Sub Public Function AddAlternatingColumns(ByVal wks As Worksheet, ByVal rngTarget As Range) As Double Dim dblReturnValue As Double Dim intLastColumn As Integer intLastColumn = wks.Range("A1").SpecialCells(xlCellTypeLastCell).C olumn Do While rngTarget.Column < intLastColumn Set rngTarget = rngTarget.Offset(0, 2) dblReturnValue = dblReturnValue + rngTarget.Value Loop AddAlternatingColumns = dblReturnValue End Function -- Thanks In Advance... Jim Thomlinson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
MapPoint Optimizing | Excel Discussion (Misc queries) | |||
optimizing code? (hide) | Excel Programming | |||
optimizing a macro | Excel Programming | |||
optimizing a lookup | Excel Programming | |||
Optimizing in VB | Excel Programming |