This looks like a decent recursive implementation. So, this is mainly about style and readability.
First, I would like to talk about two things which are really hard and could use some improvement here, naming and consistency of semantic levels. Then I have some more miscellaneous comments.
Generally, the naming is not too bad, but some of the ...
It is much faster to iterate over an array then a recordset. You should also pass the recordset to a function to return the dictionary. The fewer tasks a subroutine performs the better.
Function RecordsetMap(ByRef rs As ADODB.Recordset, ByVal KeyColumn As Long) As Scripting.Dictionary
Dim Map As New Scripting.Dictionary
Dim Key, Item, Values
I don't understand why QuickMatch would be in standard PascalCase, while getQuickRowValue would be camelCase. Public member names should be PascalCase - not something that's always obvious to do with a case-insensitive language, but it's certainly feasible. Consistency!
Dim low As Long, high As Long, pivot As Long
Dim Value As Variant, NextValue As Variant, ...
COUNTIF() is slow. A few COUNTIF() statements in a worksheet can be okay, but thousands of them will result in a glacial spreadsheet.
Here is a way to replace your COUNTIF() statements:
Sort Column A.
In Column B, have each cell check if the corresponding cell in column A is equal to the cell above it in column A. If no, put 1 in column B's cell. If yes,...
Very clean code, reads very nicely, well done!
Watch for inconsistencies in indentation:
Public Sub PrintToImmediateWindow()
Private Sub GetSystemAttributes()
Rubberduck can fix that for you (across the entire project) with a single click.
Consistent indentation is normally understood as "executable statements within a ...
The dictSessionVars is initialized together with the default instance of the class:
Private Sub Class_Initialize()
If this.dictSessionVars Is Nothing Then Set this.dictSessionVars = GetPersistentDictionary()
That's great, because it ensures you always have a valid managed storage.
That being said, If you plan to use this class in one of your
I don't mean to drag this up but have you considered a recursion function? Not so long ago I created a binary CART model in VBA that uses a basic recursive structure along the lines of:-
- Call function B to add row to output recordset object
- Check for leaf conditions; exit function early if yes
- Call function C to calculate best split and ...
My tests indicate that adding an instance of TTestClass to the AppSessionVariables Dictionary does not survive a state loss.
Private Sub SetVariable()
Adding End to SetVariable and then calling GetVariable throws this error:
Simple Key/Value pairs do, however, persist. The values persist even after closing and reopening ...
Comepletely forgot to post an answer to this, that i found a little after asking this question. Hopefully someone can use it
The code we used before was not optimal and messy, since you had to write those six lines of code for each PT, and every time you added a new PT.
I then realised you could just add some for each ... then loops that would go through ...