LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default vba Code Performance

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
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
Performance Joannie Excel Discussion (Misc queries) 2 March 26th 08 05:21 PM
Trying to improve the performance of my code Carlo Excel Programming 2 December 22nd 06 09:06 AM
Performance IF(IF or IF(AND Paul Dennis Excel Worksheet Functions 2 July 20th 06 05:24 PM
XLL performance in NT and XP [email protected] Excel Programming 3 November 21st 05 10:36 AM
Bad performance jim Excel Programming 2 January 30th 05 03:08 PM


All times are GMT +1. The time now is 06:42 PM.

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

About Us

"It's about Microsoft Excel"