Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hey again,
Does anyone have an idea what the speed differences are between for example: Dim lastRow As Long lastRow = Cells.Find("*", SearchOrder:=xlByRows, _ SearchDirection:=xlPrevious).Row ' (oldWs and newWs are WorkSheets) ' Method 1 oldWs.Range("B2:B" & lastRow).Formula = "If (RC[-1]=""yes"", 1, 0)" newWs.Columns(1).Value = oldWs.Columns(1).Value ' Method 2 Dim i As Long For i = 2 To lastRow If (oldWs.Cells(i, 1).Value = "yes") Then newWs.Cells(i, 1).Value = 1 Else newWs.Cells(i, 1).Value = 0 End If Next i In theory, I'd see Method 1 as doing a redundant operation by calculating the values into a new (later obsolete) column of the old sheet, then copying the values of that, while Method 2 directly calculates the values of the final column. However, I don't know how optimized operations on Ranges are in Excel, so can someone give me an input on which Method would be faster on large datasets, and if Method 1 is faster then by how much? Thanks! Lars |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Sumproduct against worksheet vs named range- any speed difference? | Excel Worksheet Functions | |||
charting a difference of 2 columns' w/o adding a difference column | Charts and Charting in Excel | |||
Inexplicable difference in row hiding speed - identical code, identical machines! | Excel Programming | |||
looping through ranges: how to speed up? | Excel Programming | |||
looping from one column to the next | Excel Programming |