Dataset
VBA code and spreadsheet macro datasets for AI training
A VBA code dataset is a collection of the macros businesses run inside their spreadsheets, kept in the workbooks they operate on: VBA modules, Office Scripts, Google Apps Script projects, Power Query M and the formula systems around them, with sheet structure, named ranges and buttons still attached. SourceX sources these to a buyer's spec from established businesses whose finance, operations and engineering teams keep them on shared drives and in document management systems. Each dataset is de-identified and licensed for an agreed permitted use.
Dataset manifest
Sourced to your spec- What it is
- Macro and script code delivered inside its host workbook, with the sheets, names and controls it addresses
- Typical systems
- Excel files (xlsm, xlsb, xls, xlam), Google Sheets with Apps Script, Office Scripts and Power Query, on SharePoint and shared drives
- Typical history
- Workbooks often stay in use for many years; dated saved copies stand in for version control
- Modality
- Code bound to workbook structure; sheets, formulas and controls as structured content
- Delivery formats
- Native host files, modules as text (.bas, .cls, .frm, .gs, .ts, .m) and a JSONL index of bindings
- Preparation
- Cell data de-identified together with literals in code; passwords, connection strings and file paths removed
- Licensing
- Scoped per workbook set or department; permitted use agreed per license; vendor and add-in code identified
- Availability
- Sourced to your spec; the language mix depends on the partner and is not guaranteed
What a delivery contains
Fields vary by source system and are fixed per order. A typical delivery includes:
| Field | Type | What it holds |
|---|---|---|
| host_workbook_id | string | Pseudonymous key for the workbook the code acts on, shared by the native file and every extracted unit. |
| container | object | Where the code was stored: xlsm, xlsb, legacy xls, xlam add-in, personal macro workbook, bound Apps Script project or separate Office Script (.osts) file. |
| code_units | array | Each module, script file or query with its language, kind (standard, class, sheet, workbook, UserForm) and source text. |
| origin_class | array | Per procedure: recorded, handwritten or recorded then edited, with the markers the label rests on. |
| entry_points | array | What starts each procedure: a button or shape, an event handler, a keyboard shortcut, a trigger or another procedure, with procedures nothing reaches marked. |
| object_bindings | array | Every sheet, range, defined name, table and control the code addresses, how it is addressed, and whether it resolves in the host. |
| binding_status | object | Counts of static references that resolve, that fail, and that are built at run time and cannot be checked without executing. |
| library_references | array | Object libraries and add-ins the project references, with any marked missing when the file was opened. |
| external_touchpoints | array | Database connections, file paths, other workbooks, mail and shell calls, with credentials removed and targets replaced by placeholders. |
| compile_check | object | Whether the project compiles as delivered and whether variable declaration is enforced. |
| saved_copies | array | Earlier dated copies of the host file, each with the modules that changed since the copy before it. |
| redaction | object | Counts of credentials, paths and names removed from code, comments and forms, and of literals changed to match de-identified cells. |
Field names from the table above; values are masked placeholders.
Example record
{
"host_workbook_id": "wb_7c41e0",
"container": { "kind": "xlsm", "title": "Month-end accrual loader", "sheets": 6 },
"code_units": [
{ "unit": "Module1", "kind": "standard_module", "language": "vba", "lines": 212,
"procedures": ["Macro3", "BuildAccruals", "LastRow"] },
{ "unit": "Sheet2 (Accruals)", "kind": "sheet_module", "language": "vba", "procedures": ["Worksheet_Change"] },
{ "unit": "GL extract", "kind": "power_query", "language": "m" }
],
"origin_class": [
{ "procedure": "Macro3", "label": "recorded",
"markers": ["select_then_selection", "FormulaR1C1", "SmallScroll", "default_name"] },
{ "procedure": "BuildAccruals", "label": "recorded_then_edited",
"markers": ["recorded_block_inside_loop", "On Error Resume Next", "dated_initials_comment"] },
{ "procedure": "LastRow", "label": "handwritten", "markers": ["typed_parameters"] }
],
"entry_points": [
{ "procedure": "BuildAccruals", "via": "form_button", "sheet": "Control", "caption": "Load accruals" },
{ "procedure": "Worksheet_Change", "via": "event", "sheet": "Accruals" }
],
"object_bindings": [
{ "ref": "Worksheets(\"GL_Dump\")", "by": "tab_name", "resolves": true },
{ "ref": "Range(\"B7:F40\")", "by": "fixed_address", "sheet": "active_at_run", "resolves": "depends_on_active_sheet" },
{ "ref": "Range(\"rngCutoff\")", "by": "defined_name", "resolves": true },
{ "ref": "Sheets(4)", "by": "index", "resolves": true }
],
"binding_status": { "static_refs": 61, "resolved": 57, "unresolved": 1, "built_at_run_time": 3 },
"library_references": [ { "name": "Microsoft Scripting Runtime", "missing": false } ],
"external_touchpoints": [
{ "kind": "database_connection", "value": "Provider=[PROVIDER];Data Source=[HOST_1];User ID=[USER];Password=[REMOVED]" },
{ "kind": "file_path", "value": "[SHARE_2]\\Close\\accruals.csv" }
],
"compile_check": { "compiles": true, "option_explicit": false },
"saved_copies": [
{ "file_date": "2019-03-29", "changed": ["Module1"], "note": "row limit raised from 500 to 2000" }
],
"redaction": { "credentials_removed": 1, "paths_replaced": 4, "literals_changed_with_cells": 12 }
}Synthetic record for illustration. Field names, structure and format are agreed per order.
What AI teams use it for
Repairing macros that broke
A failing procedure with its host workbook shows a model the inserted column or renamed tab behind the error, not just the error line.
Migrating VBA to newer runtimes
Bound code and its sheets support translation to Office Scripts, Apps Script or Python, with the workbook's own output as the reference.
Explaining a macro to its owner
Procedures paired with the ranges and buttons they touch train plain-language summaries of what an inherited workbook does.
Rewriting recorded code
Recorded procedures and their later hand-edited versions are examples of replacing fixed addresses with logic that survives added rows.
Grading agents by running the macro
A task can be scored by executing the code in its host and comparing the resulting sheets with the ones the original macro produced.
Use-case guides: Coding agents, Finance and accounting agents, Enterprise and computer-use agents, Private evaluation sets
What makes this data valuable
Host attached
Every code unit arrives with the workbook it acts on, in native format.
Bindings resolved after processing
The share of static references that still resolve after de-identification is reported per workbook.
Origin labeled per procedure
Recorded, handwritten and mixed procedures are labeled one by one, with the markers used.
Entry points captured
Buttons, events, shortcuts and triggers are listed, so dead code can be told from live code.
Dated saved copies
Earlier copies of the same workbook show how a macro was patched over time.
Secrets scan on record
The delivery states what was searched for in code, comments, forms and stored properties, and what was removed.
Process
VBA code dataset
Why macro code ships inside its workbook
Macro code addresses its workbook by position and by name. A line such as Range("B7:F40").Copy, Sheets(3).Activate or Worksheets("GL_Dump").Cells(i, 4) does not say what sits in column D, where the header row is or which sheet is third. Recorded code acts on Selection and ActiveSheet, so its effect depends on which sheet was in front when the button was pressed. An extracted .bas file keeps the text and loses what the text points at.
Each platform stores code in a different place and loses the binding in its own way. In an xlsm file the VBA project is one binary part. Event handlers such as Worksheet_Change and Workbook_Open fire with no caller, the link from a form button or shape to its procedure is stored with the drawing, an ActiveX button calls a click handler in the sheet's module, and saving as xlsx drops the project without a trace. Power Query M sits in a separate encoded part that text extractors often miss. Office Scripts are TypeScript saved as separate .osts files, by default in the author's OneDrive or else on a SharePoint site, and a workbook only links to them. A bound Apps Script project is attached to its Google Sheet, does not appear as a file in Drive, and is left behind when the sheet is downloaded as xlsx. Collection therefore differs per platform, and each unit should record how it was tied to its host.
De-identification can break the binding too. Code compares cells with string literals and names sheets in quotes. Replace a customer name in the cells but not in the comparison that tests for it, and a branch never runs again. Rename a tab and every Worksheets call that named it fails. Replacements have to be applied together across cells, tab names, defined names and code literals, and every static reference resolved against the processed host afterward. References built at run time, such as Range("A" & n), can only be flagged.
Recorded macros and handwritten logic
Much of this code was written by accountants, planners and engineers who began with the macro recorder. Recorder output is easy to recognize. It selects a range and then acts on Selection, writes formulas through ActiveCell.FormulaR1C1, hard-codes every address, and keeps what the author did by accident: ActiveWindow.SmallScroll lines from scrolling, Application.CutCopyMode = False after a paste, and With Selection.Interior blocks that write out properties the author never touched. Procedures keep default names such as Macro1 or Macro7 and sit in Module1. Handwritten code tends to declare variables, loop to a last row found with End(xlUp), pass parameters and handle errors.
A workbook in use for years holds both, often in one procedure. A recorded formatting block gets wrapped in a loop someone typed later. An On Error Resume Next is added to silence a failure. Old versions stay commented out under initials and dates. The label therefore belongs to the procedure, not the file, and should name the markers it rests on.
Both kinds matter. A recorded macro is a literal trace of what a person did in the application, and it is the code people most often ask an assistant to fix so that it still works when rows are added. Handwritten procedures carry the business rule: which accounts are accrued, what tolerance raises a warning. The patches show how this code fails in practice: an inserted column, a renamed tab, a missing library reference, a move to 64-bit Office that broke declarations of external functions. Clean handwritten modules alone misrepresent what a spreadsheet assistant meets, so state the mix you want.
What to check before licensing
- Open sample host files and confirm the code is inside the native workbook, not only in extracted text. Ask what share of code units has no host.
- Ask for the binding check run after de-identification: how many static references resolve, how many fail and how many are built at run time.
- Check that workbook cell data is de-identified wherever code can read it, including hidden sheets, UserForm captions and default values, cell comments and document properties.
- Search the code for hard-coded passwords and connection strings, passwords passed to Unprotect, keys held in Apps Script properties, network paths and user names inside file paths. Confirm they were removed.
- Ask how recorded and handwritten procedures were told apart, and check a sample of each label against its markers.
- Confirm the partner owns the code. Workbooks often hold vendor add-ins, consultant-written modules and snippets copied from forums, and a project locked for viewing must be opened by its owner.
- Ask which macros were executed after processing, and which depend on databases, shared folders, other workbooks or mail clients that are not in the delivery.
Delivery No files move before a signed license. A listing or a request grants no files by itself.
How licensing works through SourceX
- 1
Define
Send the domain, modality, volume, format, timeline and permitted use you need.
- 2
Source
SourceX identifies businesses that hold matching data and are open to licensing it.
- 3
Qualify
Fit, rights and quality are checked, and you review samples before committing.
- 4
License
Scope, permitted use, exclusivity, price and obligations are agreed in writing.
- 5
Deliver
Approved data is prepared, de-identified where required and transferred securely.
Questions Acquisition Partners ask
Why is the code delivered inside workbooks instead of as source files?
Because the code only has meaning against the workbook it acts on. A macro refers to sheets, ranges and names by position and by text, and a button or an edit event starts it. Extracted modules keep the syntax and lose all of that. The text is still supplied alongside.
Which languages and file types can be included?
VBA in xlsm, xlsb, legacy xls and xlam add-in files, Office Scripts (TypeScript, stored as .osts files), Apps Script projects bound to Google Sheets, Power Query M and, where you ask for them, formula systems such as LAMBDA libraries. Older workbooks may also hold Excel 4.0 macro sheets. Say which languages you need and in what proportion.
How do you tell recorded macros from handwritten code?
By markers in the code, applied per procedure. Recorded code selects before it acts, uses fixed addresses and R1C1 formulas, keeps scroll and clipboard lines, and carries default names. Handwritten code declares variables, loops and takes parameters. Many procedures are recorded and then edited, so there is a third label.
How are passwords and connection strings in macros handled?
They are removed before delivery, and the method is recorded for each dataset. Ask for typed placeholders in their place, so a connection string keeps its shape. Macros often embed database logins, sheet protection passwords and network paths, and Apps Script projects can hold keys in stored properties outside the code. No scan is perfect, so run your own secret scanner over the sample.
Can the macros still run after de-identification?
Only code that depends on nothing outside its own workbook, and only if replacements were applied to cells and code literals together. Code that reads a database, a shared folder or another workbook stops at that call unless the target is delivered or stubbed. Ask which macros were executed after processing and what happened.
How is this different from a spreadsheet and financial model dataset?
The unit here is the procedure and what it is bound to, not the cell and its formula. A spreadsheet model dataset is selected for formula logic and may carry macros as an attachment. Here workbooks are chosen because they automate something, and each comes with entry points, bindings and origin labels.
Related datasets
- Real-world spreadsheets and financial models
Working Excel and Google Sheets files with formulas, links and version history
- Low-code and no-code app definitions
Exported app and automation definitions with data models, formulas, flow steps, connectors, saved versions and run logs
- Legacy and rare-language codebases
Private production code in under-represented languages, with copybooks, job control, data definitions and change history
- RPA bot logs and process definitions
Bot workflow files with selectors, branches and handlers, joined to queue items, job runs, logs and published versions
- Spreadsheet task sessions
Ordered cell-level logs of analysts building workbooks, with the brief, starting files and finished workbook
Evaluating this data for procurement?
Diligence packets are prepared per dataset. Rights, privacy processing and quality differ between datasets.
Request dataset diligenceTell us what your models need
Send your spec — domain, volume, format, timeline and permitted use — and SourceX will match it against partner data and come back with what can be licensed.
Updated 25 November 2026.