Slow array data in multiple workbooks

jfklbj

Board Regular
Joined
Feb 9, 2009
Messages
68
I have stored arrays that I want to transfer from one workbook to another. When I run the code in one workbook, it's fast and efficient. If I try to transfer the data to another workbook, it's slow as sin. The code is like this.

BillItemTypeSVC = [StoredSVC]
BillItemTypeDesc = [StoredDesc]
BillItemTypeUnits = [StoredUnits]
BillItemTypeDebit = [StoredDebit]
BillItemTypeUnitPrice = [StoredUnitPrice]
For iX = 1 To 72
With Workbooks("CAS").Sheets("BilledItems").Range("A13")
.Offset(iX, 0) = BillItemTypeSVC(iX)
.Offset(iX, 1) = BillItemTypeDesc(iX)
.Offset(iX, 2) = BillItemTypeUnitPrice(iX)
.Offset(iX, 3) = BillItemTypeUnits(iX)
.Offset(iX, 4).Value = BillItemTypeDebit(iX)
End With
Next iX

If I run this within a single workbook, the macro takes a fraction of a second. If I transfer to a new workbook, each loop takes over a second. (About 90 sec. for this macro). Any ideas why so slow?

Thanks,

Mike
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
why not just write the array to the rang instead of looping through it?

Code:
with Workbooks("CAS").Sheets("BilledItems")
   .Range(.range("A13"),.range("a13").offset(ubound(BillItemTypeSVC),0)) = application.worksheetfunction.tanspose(BillItemTypeSVC)
    ' etc
i did not test this and may have go confused, but that is the general idea
 
Upvote 0
The solution was simple enough

Application.Calculation = xlManual was all that was needed.

Then I changed calculation back to automatic after the loops were completed.

Thanks anyway.
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,211
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top