ClimoC
Well-known Member
- Joined
- Aug 21, 2009
- Messages
- 584
Hello,
so kind of two questions:
I have a 'data' sheet (table) hidden, and to optimise speed at run-time I load the thing in an array...
...as well as having a bunch of Global Bytes for 'Finding' the column headers for use in reading/writing to the DB.
But considering we estimate this thing to get to 30/40,000+ rows in time at it's greatest, I thought that loading this all into memory every time we run a procedure that looks up values from the table, would just become tedious (and obviously, the reason you usually do anything in VBA is to save time and hassle...)
So my first question is probably a REALLY stupid one...
1. Is there a way to load a 'Variant Array' like mine into memory, and it's just permanently there for all future procedures to just go straight to the read/writing without having to load it each time?
2. Is it FASTER (for future proofing), and ideally, provides the kind of 'live' and 'ready-access' functionality described about, To do this all through ADO with a little .mdb file created? And by that I mean without 'Access' and servers, I mean write out the 'Data' sheet to an .mdb file when you first open the workbook to the C:\ and link into that instead.
Any advice on these would be appreciated. I don't want to be asked to rewrite the code in 6 months time because it takes 30 seconds to do ANY of the whizzy functions I'm building in to the UI side of it.
Thanks
C
so kind of two questions:
I have a 'data' sheet (table) hidden, and to optimise speed at run-time I load the thing in an array...
Code:
Global RecDict As Object, Database() As Variant,
Sub Startup()
Dim RecStore As Range
Database() = Sheets("Data").Range("A2:Z" & Sheets("Data").Range("A65000").End(xlUp).Row).Value
Set RecDict = CreateObject("Scripting.Dictionary")
For Each RecStore In Sheets("Data").Range("A2:A" & Sheets("Data").Range("A65000").End(xlUp).Row)
If Not RecDict.exists(RecStore.Value) Then RecDict.Add RecStore.Value, RecStore.Row
Next
...as well as having a bunch of Global Bytes for 'Finding' the column headers for use in reading/writing to the DB.
But considering we estimate this thing to get to 30/40,000+ rows in time at it's greatest, I thought that loading this all into memory every time we run a procedure that looks up values from the table, would just become tedious (and obviously, the reason you usually do anything in VBA is to save time and hassle...)
So my first question is probably a REALLY stupid one...
1. Is there a way to load a 'Variant Array' like mine into memory, and it's just permanently there for all future procedures to just go straight to the read/writing without having to load it each time?
2. Is it FASTER (for future proofing), and ideally, provides the kind of 'live' and 'ready-access' functionality described about, To do this all through ADO with a little .mdb file created? And by that I mean without 'Access' and servers, I mean write out the 'Data' sheet to an .mdb file when you first open the workbook to the C:\ and link into that instead.
Any advice on these would be appreciated. I don't want to be asked to rewrite the code in 6 months time because it takes 30 seconds to do ANY of the whizzy functions I'm building in to the UI side of it.
Thanks
C
Last edited: