Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all,
I am experiencing a performance issue with my vba code. I think that I'm making a mistake somewhere since a similar code this used to run alot faster. Here are the details: - I have tested the code on both Excel 2002 and 2003 - The code that seems to be causing the problem is this: Sub importItems(ByRef sourceRange as Range, ByRef destinRange as Range, ByRef sourceWB As Workbook, ByRef rowTotal As Long) On Error GoTo ErrHandler: Dim dataRow as Range Dim rowCount as Long Dim readRows as Long Dim totalRows as Long rowCount = 0 readRows = 0 totalRows = sourceRange.Rows.Count For Each dataRow in sourceRange.Rows If dataRow.Cells(1, 2) = "Yes" Then With dataRow rowCount = rowCount + 1 destinRange.Cells(rowCount, 1) = .Cells(1, 1) destinRange.Cells(rowCount, 2) = .Cells(1, 9) destinRange.Cells(rowCount, 8) = WorksheetFunction.VLookup(.Cells(1, 14), sourceWB.Sheets("Releases").Range("Data"), 2, False) destinRange.Cells(rowCount, 9) = .Cells(1, 7) End With End If readRows = readRows + 1 frmImport.prg_import.Value = (readRows / totalRows) * 100 Next dataRow rowTotal = rowCount Exit Sub ErrHandler: MsgBox "An error occured: " & Err.Description & " (" & Err.Number & ")", vbCritical, "Temp Data Procedure Error" End Sub - The code is intended to import some data from another excel file. The amount of data that is transfered is about 13 x 1600. The function works, but it is extremely slow. I had pretty much the same code inside my calling function and it was a lot faster. Once I moved the code into a seperate procedure, the performance took a big hit. I'm not sure what could be the problem. If anyone wants to see the complete file, I'll be happy to provide it. Thanks in advance for all help |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Performance | Excel Discussion (Misc queries) | |||
Trying to improve the performance of my code | Excel Programming | |||
Performance IF(IF or IF(AND | Excel Worksheet Functions | |||
XLL performance in NT and XP | Excel Programming | |||
Bad performance | Excel Programming |