Performance Question - Access to Excel

JeffK627

Active Member
Joined
Jun 22, 2005
Messages
313
I'm building an application that stores data in an Access database and displays it in an Excel spreadsheet. The data in the database is stored in the following columns: Product, BusinessUnit, ProductCode, State, Quarter, TypeAUnits, TypeBUnits.

The user wants the data broken out by Quarter, i.e., TypeAUnits and TypeBUnits for Quarter 1 of 2008, then Quarter 2 of 2008, etc. up to the current Quarter. There are over 300,000 total rows in the table, and about 26,000 rows per Quarter.

Where I run into a problem is that there aren't necessarily unit numbers for every Product Code in every Quarter, so I have to match the TypeAUnits and TypeBUnits up with the right ProductCode and State, row-by-row. The Product, BusinessUnit, ProductCode and State columns on the Excel sheet are already populated. This is the code I'm currently using, where rst1 is the recordset obtained by selecting all fields from the table where Quarter = the desired quarter:

Code:
For i = 11 To lastRow
  If rst1!ProductCode = Sheet1.Cells(i,3) AND rst1!State = Sheet1.Cells(i,4) Then
    Sheet1.Cells(i,5) = rst1!TypeAUnits
    Sheet1.Cells(i,6) = rst1!TypeBUnits
  End If
Next

This is taking forever to run. I have Screen Updating set to False and Calculation set to XLManual, can anyone think of another way to speed this up?
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,224,598
Messages
6,179,823
Members
452,946
Latest member
JoseDavid

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