Getting started

Overview

Reusable VBA tools for transforming Excel arrays, filtering records, and calculating statistics in memory.

The library#

VBA-DataKit is a reusable data manipulation library developed from scratch during a trading internship. Originally built for financial data processing in Excel, it provides tools for filtering, stable sorting, grouped statistics, array reshaping, and Excel automation.

Read a rectangular range once, transform its Variant array in memory, and write the result in one operation. The library brings a familiar array-oriented workflow to VBA projects.

API reference

Explore 26 public procedures across three utility classes — Arrays, Finance and Others — plus six enumerations. Browse the API reference or follow the installation guide to add the library to your VBA project.

Explore the modules#

Add it to your project#

Enable Microsoft Scripting Runtime in the VBA editor under Tools → References. The library requires it for its Dictionary objects.

Import the Arrays, Finance and Others class modules into your VBA project. Create the shared instances in a standard module. See Installation for the full steps.

Create a shared instance in a standard module:

VBA
Public Arr As New Arrays

Then call methods through that name, for example result = Arr.Sort(data, 2, 1). If you know Python’s import numpy as np, the idea of a short, consistent name will feel familiar. In VBA, Arr is an object instance of the Arrays class. Declare the shared instances only once in your project.

SEE THE TRANSFORMATIONKeep Posted rows, then sort amount descending
Before
A2:C6 values2D · 5 × 3

Rows 1..5 · Columns 1..3

row / col123
1“North”120“Posted”
2“South”80“Pending”
3“North”250“Posted”
4“West”45“Posted”
5“South”200“Pending”
After
Result written from E22D · 3 × 3

Rows 1..3 · Columns 1..3

row / col123
1“North”250“Posted”
2“North”120“Posted”
3“West”45“Posted”

Shape sequence: 5 × 3 → 3 × 3 → 3 × 3. Headers are outside the arrays.

Shaded headers are array indices, not data. Quoted cells are text. Values shown are derived from the source, not an Excel execution.

Read, transform, write#

For this example, enter the Before table’s data in A1:C6 on the workbook’s first worksheet. The macro reads only the data rows and writes matching records to E2:G6. Existing cells in that destination may be overwritten; rows beyond the new result are not cleared.

VBA
Sub QuickStart()
    ' Requires the library classes and shared instances in this project.
    ' A2:C6 contains Region, Amount, Status; headers are in row 1.
    Const OP_EQUAL As Long = 1000 ' ResearchType.eEqual
    Dim ws As Worksheet
    Dim data As Variant, result As Variant
    Set ws = ThisWorkbook.Worksheets(1)

    data = ws.Range("A2:C6").Value2
    result = Arr.Filter(data, 3, OP_EQUAL, "Posted")
    If Not IsArray(result) Then
        Debug.Print "No matching rows"
        Exit Sub
    End If

    result = Arr.Sort(result, 2, 0) ' 0 = descending
    ws.Range("E2").Resize(UBound(result, 1), _
        UBound(result, 2) - LBound(result, 2) + 1).Value2 = result
End Sub

The filter preserves matching-row order, and Sort returns a descending copy. Keep header rows outside the array unless you want them processed as ordinary data.

Where to go next#

VBA-DataKit · Developer documentation.