r/vba 4d ago

Weekly Recap This Week's /r/VBA Recap for the week of July 11 - July 17, 2026

1 Upvotes

r/vba 1d ago

Show & Tell What if VBA had a modern developer experience?

26 Upvotes

I've been building an open-source project called xlflow after repeatedly running into the same problems while maintaining large VBA codebases:

  • Source code trapped inside .xlsm, .xlam, and .xlsb files
  • Awkward Git workflows
  • Limited editor support
  • Difficult testing and automation
  • Coding agents unable to reliably interact with Excel and VBA

xlflow treats VBA projects as regular source code and provides both a VS Code development environment and a fully scriptable CLI workflow.

VBA development in VS Code

The VS Code extension includes:

  • Autocompletion
  • Real-time diagnostics
  • Go to Definition
  • Hover information
  • Signature help
  • Symbol navigation
  • Static analysis
  • Formatting

It is powered by a custom VBA parser that currently cleanly parses more than 170 test corpora and 300 real-world VBA source files.

One feature I'm especially happy with is type inference for late-bound COM objects.

Dim dict As Object
Set dict = CreateObject("Scripting.Dictionary")

Even though dict is declared as Object, the extension can infer the type from CreateObject() and provide member completion, hover information, and type-aware diagnostics.

This also works with common late-bound libraries such as Excel, Scripting, ADODB, and other COM APIs.

Git-friendly workbook development

xlflow can extract VBA projects into normal source files and synchronize them back into Excel workbooks.

This makes it possible to:

  • Store VBA projects in Git
  • Review changes using normal diffs
  • Use branches and pull requests
  • Edit code outside the VBE
  • Define UserForms as version-controlled YAML

Everything is available from the CLI

All workbook operations can be executed from the terminal:

xlflow pull
xlflow test
xlflow lint
xlflow push

The CLI can also run macros, manage Excel sessions, format code, inspect projects, and execute tests.

This was an important design decision because it allows the same workflow to be used by developers, CI pipelines, scripts, and coding agents.

Designed for coding agents

A major goal of xlflow is to make autonomous VBA development practical.

Since the source code is stored as normal files and every operation is exposed through the CLI, tools such as Codex, Claude Code, and Cursor can:

  • Modify VBA source code
  • Run unit tests
  • Read compiler and runtime errors
  • Lint and analyze the project
  • Push changes back into the workbook
  • Generate and update UserForms

Excel automation normally has another major problem: modal error dialogs can block execution indefinitely.

xlflow monitors many Excel and VBA dialogs, captures their contents, and reports the errors back to the terminal instead of leaving the workflow blocked behind a GUI window.

That means a coding agent can see the failure, modify the code, rerun the tests, and continue working without waiting for someone to manually dismiss an Excel dialog.

GitHub:

https://github.com/harumiWeb/xlflow

VS Code Marketplace:

https://marketplace.visualstudio.com/items?itemName=harumiWeb.xlflow-vscode

I'd be very interested in feedback from people maintaining real-world VBA projects.

What are the biggest limitations in your current VBA development workflow?


r/vba 1d ago

Unsolved How do you deal with processing large data?

5 Upvotes

As in the title - how do you do this. Currently I am working in large bank but we're interning at big bank but building useful macros are nightmare since it's processing so long. The reason behind it is also because of hardware and working on virtual machines but it's still much too slow - the excel can crash and we're talking about 24000 rows+. Would you suggest some alternatives?


r/vba 2d ago

Show & Tell [Updated] WebDriver BiDi for SeleniumVBA

4 Upvotes

Hi everyone,

I have been developing an open-source project called WebDriver BiDi for SeleniumVBA.

It is a WebDriver BiDi client and automation wrapper designed to let Excel VBA work with modern web applications without requiring .NET, Python, or Node.js.

GitHub:

https://github.com/hanamichi77777/WebDriver-BiDi-for-SeleniumVBA

Why I created it

Traditional Selenium-style commands are often sufficient for simple pages, but modern SPAs can be difficult to automate reliably.

A click may return successfully while the application is still:

  • processing Fetch or XHR requests,
  • replacing DOM elements,
  • rendering content asynchronously,
  • recreating browsing contexts or JavaScript realms,
  • or updating components inside Shadow DOM.

For this reason, the project focuses not only on sending browser commands, but also on observing what happens after each operation.

Main features

  • Direct WebDriver BiDi communication from VBA
  • WebSocket communication implemented with Windows APIs(WinSock)
  • Chrome and Edge support(Note: Firefox is not supported.)
  • SPA synchronization using network activity, DOM mutations, Fetch/XHR activity, and stability windows
  • Shadow DOM clicking and input
  • Automatic recovery when the SPA observation probe is lost during navigation
  • Resource blocking for ads, analytics, fonts, and other unnecessary requests
  • WebDriver BiDi webExtension.install support
  • Detailed request, response, heartbeat, recovery, and SPA activity logs
  • A Discovery Log for analyzing unknown third-party SPA behavior

The Discovery Log is particularly useful when a site does not expose a clear “ready” or “completed” state.

It records network responses, DOM mutation bursts, ignored background noise, and stability timing. The resulting log can also be provided to an AI assistant to help identify useful completion signals, noise filters, and safer waiting conditions.

Example scenarios

I have tested the project with applications such as:

  • Google Flights
  • ServiceNow
  • dynamically rendered scraping test sites
  • pages using nested Shadow DOM
  • Chrome extension installation through WebDriver BiDi

For example, the Google Flights demo performs destination selection, calendar interaction, date selection, and flight-result synchronization while observing both network and DOM activity.

Reliability design

One of the difficult parts was retry behavior.

When a browser command times out, the action may already have succeeded in the browser. Automatically repeating a click or input could therefore cause a duplicate operation.

The wrapper distinguishes between:

  • operations that are safe to retry,
  • transient context or realm failures,
  • and ambiguous outcomes where automatic retry should be stopped.

The goal is to improve recovery without hiding failures or accidentally executing state-changing operations twice.

VirusTotal Scan Results

WebDriver BiDi for SeleniumVBA v3.0 was scanned by VirusTotal on July 22, 2026, and received 0 detections from 64 security vendors at the time of testing.


r/vba 2d ago

Show & Tell Thumbnails LibRetro Downloader 2.2 - Selenium Basic (Excel VBA)

0 Upvotes

Hello gamers, and welcome to another one of my videos! In this video, we are going to use my Thumbnails Libretro Downloader, version 2.2 (Selenium.xlsm). This is an upgraded version of the tool shown in my previous video. It features improved element searches using XPath, which significantly cuts down execution time. Additionally, it can now download images even when the filename contains characters, that previously caused version 1.0 to throw an error. With these changes, we can also search for specific titles using keywords unique to that game. Furthermore, I have removed the need to specify the system name. Instead, you can now just type a partial name into the dropdown menu, and the search list updates automatically. Finally, I added a new function to delete unwanted images from your local folder. It seems like a lot to cover, so let's go!

https://youtu.be/YO7QmmyfRM4


r/vba 2d ago

Unsolved Vbagx on wii is messing up certain colors

0 Upvotes

So ive just got vbagx on my wii and ive tried three games and each has problems with certain colors. The opening of Buu's fury is all neon green, Aria of Sorrow has the same problem but in game in the water areas the water is neon green and Pokemon Fire Red has that problem as well. Ive messed with filters and settings but have been unable to find the solution. Any help is appreciated.


r/vba 5d ago

Show & Tell [Word] Just open-sourced a text to coding case converter (like camelCase or snake_case)

Thumbnail github.com
2 Upvotes

Also proposing the term inchworm case for alternating words in subscript and superscript like so: ᵢₙ꜀ₕʷᵒʳᵐ꜀ₐₛₑ

And ʀʜɪɴᴏCᴀsᴇ for camelCase with small caps.


r/vba 7d ago

Discussion SeleniumVBA: Maintaining WebElements object when navigating to different pages

9 Upvotes

I am searching my insurance company's list of providers. When I get the search results, the most relevant information for each provider is on a linked page -- not in the search results. I attempted to scrape this with seleniumvba, to gather up the info on the linked pages. Of course, when I click a link, the elements on the search results page go stale. Normally I would create two webdriver objects and pass the value from the hrefs of the first driver to the second driver.

Unfortunately, the links on this site have no href values.

<a _ngcontent-ng-c7169104465="" role="link" tabindex="0" class="dls-heading-3-light search-result-link" data-cy="search-results.name-link-0.desktop" data-lnp="search-results.provider-name">
    <span _ngcontent-ng-c7169104465="" data-cy="search-result-ProviderName" data-pendo="profile-card-provider-name" class="underline search-result-link font-light">Joe Schmoe, MD</span><span _ngcontent-ng-c7169104465="" class="disclaimers-icons ng-star-inserted">&nbsp;&nbsp;†</span><!----><!---->
</a>

What strategies have you used to hold a page in memory, but navigate to the links specified on that page? What I have so far:

Sub ScrapeProviders()
Dim WD As WebDriver
Dim ProviderCards As WebElements, ProviderCard As WebElement
Dim ProviderCardWho As WebElement, ProviderCardLink As WebElement

    Set WD = New WebDriver
    WD.StartFirefox
    WD.OpenBrowser
    WD.NavigateTo "https://carefirst.sapphirecareselect.com/search/name/orthopedic?ci=dft-sso-bluechoiceadvantage20&network_id=109&geo_location=33.684617,-117.82634&locale=en&limit=10&radius=10&sort=tiers:tiercf%20asc,%20motive_high_quality%20desc,%20distance%20asc,%20has_ep002%20desc&sort_translation=app_global_sort_relevancy&page=1"
    WD.ActiveWindow.Maximize
    While Not WD.IsPresent(XPath, "*//mat-card")
    Wend
    Set ProviderCards = WD.FindElementsByXPath("*//mat-card")
    Debug.Print ProviderCards.Count
    For Each ProviderCard In ProviderCards
        Debug.Print "====================================================================================="
        Set ProviderCardWho = ProviderCard.FindElementByXPath("./div/div/div/div[1]/div/div[1]")
        Set ProviderCardLink = ProviderCardWho.FindElementByXPath("./h2/a")
        Debug.Print ProviderCardLink.GetOuterHTML
        ProviderCardLink.Click

        ' at this point, i can no longer see ProviderCards, and the for each breaks
    Next ProviderCard

    WD.CloseBrowser
    WD.Shutdown

End Sub

r/vba 8d ago

Solved [WORD] Enabling dictionaries with VBA

5 Upvotes

Hi,

I need to fully activate custom dictionary files via VBA with no user input required.

I've written a VBA script running in a .dotm placed in ...AppData\Roaming\Microsoft\Word\STARTUP with the goal of locating and enabling dictionaries placed in ...AppData\Roaming\Microsoft\UProof and then activating them with

Application.CustomDictionaries.Add(myDictPath)

Inside an AutoExec sub.

When run, the code successfully adds a dictionary to the Custom Dictionaries list in Word, and checks the box next to the dictionary, however it still marks dictionary words as incorrect until I open the Custom Dictionaries window and close it again by hitting 'OK'.

I have tried toggling spell check off then on again immediately after the dictionaries are loaded, I have also tried manually running the macro after a document has been opened, neither work.

Any suggestions?


r/vba 8d ago

Solved [EXCEL] Getting variable 3 digits from longer, per-cell information string, into a specific column and formatting

0 Upvotes

Hello, I am attempting to setup a macro for a daily file that I/we run to save some time formatting. I'm on mobile so apologies on formatting, likewise the SS are photos as I don't have access to reddit on my workstation.

Scope: Daily file across 6 countries with an additional once per month on 3 countries. Excel is 2016 if relevant. (no xlookups)

Objective: Download a file from a platform with rejection results on attempted charges and format it so it displays the amount, date and rejection reasons per invoice number, as part of a longer daily activity. These reason codes are in longer strings of information that can vary their location per each file.

Turning: https://i.imgur.com/sd2cPR3.jpeg To https://i.imgur.com/URQkaDc.jpeg

Files currently used to perform task: Rejected Charges (csv downloaded) Macro (a sheet containing several macros for the same overall activity) Rejection codes (a sheet containing a header template on one sheet and reason codes and their descriptions on another sheet) Source files (daily files processed containing other information)

How task is currently done: Open csv file (this is saved at start or end as xls), delete B row, create header filter, replace "merchantReferenceCode=" with blank (so column A always returns the invoice number), then using column G as a reference, we replace the following with blanks: ccAuthReplyreasonCode= ccAuthReply reasonCode= The codes are usually after the above strings within column G This should leave us with something like this https://i.imgur.com/NqizfO8.jpeg

Column "G" will have most of the codes already filled out with some blanks in the mix, where remaining codes will be on different columns, like C, K, L, R, W (these codes can be duplicate, being in G and other columns)

Depending on the volume of the file we then manually copy the missing codes to G or use filters to get them

After all codes are under G we format as per the 2nd SS, by deleting all colums apart from A and G, leaving us with the invoice numbers and codes.

We then add a B column between the invoice numbers and codes Convert A and B to numbers, remove 2 decimals on A, copy and paste header from Rejection Codes file's first sheet Add new sheet, copy the contents from Rejection Codes 2nd sheet Vlookup on E referencing codes on E with C of the 2nd sheet Add today's date to column D using format dd.mm.yyyy

Vlookup on column B, referencing A against source files column F to get the amount so we end up with the final result from the second SS.

This final Vlookup I don't expect to automate, as it would always reference different files that are generated daily, so ideally the macro would do everything else leaving just column B blank so we can manually Vlookup the amounts.

I tried manually recording but my biggest hurdle is getting the reason codes from the strings of information. I can't conceive of a way of how to even get these as the 3 digit codes can be on any string on any cell. The file can go up to O or all the way to Z

I have manually recorded (using the macro sheet to save it on) the replacing the strings with blanks so I get G with with most of the codes so I then manually fetch the remaining. I had to troubleshoot as the recording I made was not working with other workbooks, but got it working now. This saves some time, but is incomplete.

I then tried recording a 2nd part post getting all the codes to do the final steps of adding the header, new sheet with the table, Vlookup the reason descriptions, add date. Leaving just the amount column empty as those Vlookup will always reference different files.

But this did not work as I get "Run-time error '9": subscription out of range https://i.imgur.com/3nd23Rm.jpeg

Looking at the debug I imagine this is because I am copying and pasting the table from a separate sheet Now this step is a bit redundant as we don't need to copy the table with the codes description to then Vlookup in the file. We could just Vlookup against the reference file. However, since I was already automating the steps, I thought I would be able to have the macro create the table and reference it on its own

Please let me know if I need to provide any additional information that I did not consider.


r/vba 8d ago

Solved Issue pasting a variant array onto sheet in loop

1 Upvotes

I have been trying to figure this out for about two days now. Claude has been of little help. Basically I have a loop that reads from a txt file, ..does some stuff.. and then pastes a variant array onto the spreadsheet. This works well for about 18 iterations and then each subsequent paste results in missing data. If I stop the code to look at the array the data is there but when it gets pasted to the sheet some of it is missing. The missing data is surrounded by data that pastes successfully. Anyone have any experiences like this that can help?

Edit: Solution found, for those playing along at home it was a logic fault in the code that was exposed when running in a loop. A particular string was doubling in size each iteration. Once this string exceeded 63,535 chars it crossed the 16bit length field boundary in old COM/BSTR marshalling. This silently corrupted and dropped elements in the transfer rather than raising an error (thanks microsoft).

For those who genuinely attempted to understand the problem and help thank you sincerely.

For those who failed to correctly read my post and as a result asked inane questions, well, at least you tried.

Foro those who immediately implied I didn't know what I was doing, congratulations, you have made this sub and the world at large a slightly worse place.


r/vba 9d ago

Show & Tell Selenium Basic - XPath Generator v1.0 in [EXCEL] VBA

1 Upvotes

- show you how to generate and customize XPaths using my Excel VBA tool, 'Selenium Basic - XPath Generator 1.0.xlsm'.

This tool easily create accurate XPaths for web elements.

- download and install Selenium Basic v2.0.9.0

- download the Chrome WebDriver, and learn how to install it either manually or via a batch file.

-Reference the Selenium Type Library in Excel VBA.

It is in my YouTube Channel.

Jaafar Yusof


r/vba 10d ago

Show & Tell [EXCEL] Pivot Table: Populate, change, or remove row/column/page/data fields in a pivot table

2 Upvotes

Independently populate, change, or remove fields in all four sections of a pivot table

Sub pivFields(argPivot As PivotTable, Optional argRows As String, Optional argCols As String, Optional argPage As String, Optional argData As String)
'set the fields in a section of the pivot (replaces existing fields)
'enter options as comma-separated strings of field names (EXCEPT data: one field only)
'field names are case-sensitive, leave option blank or "" to ignore a section, enter "X" to clear a section (any string that does not result in a good field name will do)
'e.g. change the rows, ignore the columns, clear existing page fields, ignore the data:
'   pivFields Sheets("Sheet42").PivotTables("pivName"),"Proj,Dept,Acct" , , "x"

    Dim pt As PivotTable
    Dim ptfld As PivotField
    Dim arrRows() As String
    Dim arrCols() As String
    Dim arrPage() As String
    Dim ctr As Integer
    Dim boolData As Boolean

    Set pt = argPivot
    If pt Is Nothing Then Exit Sub

    Application.ScreenUpdating = False

    If argRows <> "" Then
        arrRows() = Split(argRows, ",")

        For Each ptfld In pt.RowFields
            ptfld.Orientation = xlHidden
        Next ptfld

        For ctr = 0 To UBound(arrRows)
            For Each ptfld In pt.PivotFields
                If ptfld.Name = arrRows(ctr) Then pt.PivotFields(ptfld.Name).Orientation = xlRowField
            Next ptfld
        Next ctr
    End If

    If argCols <> "" Then
        arrCols() = Split(argCols, ",")

        For Each ptfld In pt.ColumnFields
            ptfld.Orientation = xlHidden
        Next ptfld

        For ctr = 0 To UBound(arrCols)
            For Each ptfld In pt.PivotFields
                If ptfld.Name = arrCols(ctr) Then pt.PivotFields(ptfld.Name).Orientation = xlColumnField
            Next ptfld
        Next ctr
    End If

    If argPage <> "" Then
        arrPage() = Split(argPage, ",")

        For Each ptfld In pt.PageFields
            ptfld.Orientation = xlHidden
        Next ptfld

        For ctr = 0 To UBound(arrPage)
            For Each ptfld In pt.PivotFields
                If ptfld.Name = arrPage(ctr) Then pt.PivotFields(ptfld.Name).Orientation = xlPageField
            Next ptfld
        Next ctr
    End If

    If argData <> "" Then
        For Each ptfld In pt.DataFields
            ptfld.Orientation = xlHidden
        Next ptfld

        For Each ptfld In pt.PivotFields
            If ptfld.Name = argData Then boolData = True
        Next ptfld

        If boolData = True Then
        With pt.PivotFields(argData)
            .Orientation = xlDataField
            .Caption = "Sum of " & argData
            .Function = xlSum
        End With
        End If
    End If

    Application.ScreenUpdating = True

End Sub

r/vba 10d ago

Show & Tell [EXCEL] Pivot Table: Create pivot table in the old-school tabular format

1 Upvotes

Create a pivot table in the old-school tabular format. Optionally specify the sheet to pivot (else it uses ActiveSheet). Optionally name the resulting sheet (else whatever Excel names it). Reuses cache when possible so pivoting the same data multiple times doesn't create a new cache each time.

Function pivCreate(Optional argSheet As Worksheet, Optional argName As String) As PivotTable

    Dim wks As Worksheet
    Dim pc As PivotCache
    Dim pcSource As String
    Dim pcIndex As Integer

    Set wks = argSheet
    If wks Is Nothing Then Set wks = ActiveSheet

    'compose a string of the source data that will be used
    pcSource = wks.Name & "!" & wks.UsedRange.Address(ReferenceStyle:=xlR1C1)

    'check if an existing pivot cache already uses that source data
    For Each pc In ActiveWorkbook.PivotCaches
        If pc.SourceType = xlDatabase And Replace(pc.SourceData, "'", "") = pcSource Then
            pcIndex = pc.Index
            Exit For
        End If
    Next pc

    If pcIndex = 0 Then     'no cache found for the source data.  create a new one
        Set pc = ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=wks.UsedRange.Address, Version:=xlPivotTableVersion10)
    Else                    'use the existing cache
        Set pc = ActiveWorkbook.PivotCaches(pcIndex)
    End If

    Sheets.Add After:=wks

    Set pivCreate = pc.CreatePivotTable( _
        TableDestination:=ActiveSheet.Name & "!R3C1", _
        TableName:="piv" & wks.Name)

    'QOL settings for xlPivotTableVersion10 (tabular pivot)
    With pivCreate
        .DisplayImmediateItems = True
        .ShowDrillIndicators = False
        .ShowPageMultipleItemLabel = True
        .SmallGrid = False
    End With

    If argName <> "" Then ActiveSheet.Name = argName

    ActiveSheet.Cells(3, 1).Select

End Function

r/vba 11d ago

Weekly Recap This Week's /r/VBA Recap for the week of July 04 - July 10, 2026

1 Upvotes

r/vba 12d ago

Solved Type mismatch with SetSourceData

3 Upvotes

hey guys, I need some help figuring out why SetSourceData is not working. I'm pretty new to VBA and have basically been teaching it to myself for this project, so I'm feeling a bit lost here. I am giving it a range, but I keep getting a type mismatch error. Any advice?

Sub bar_chart_test_2()

Dim objWord
Dim objDoc
Dim objSelection
Dim i As Integer
Dim j As Integer
Dim ws As Worksheet

'get spreadsheet and data range
Set ws = ThisWorkbook.Sheets("lookup")
ws.Activate

Dim quarterData As Variant
Dim hoursQtrData As Variant
Dim bookingsData As Variant
Dim roomTypeData As Variant
Dim hoursRoomData As Variant

quarterData = ws.Range("C25:C41").Value2
hoursQtrData = ws.Range("I25:I41").Value2
bookingsData = ws.Range("H25:H41").Value2
roomTypeData = ws.Range("C15:C21").Value2
hoursRoomData = ws.Range("I15:I21").Value2

'create word document and open
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add
Set objSelection = objWord.Selection
objWord.Visible = True
objWord.Activate

Dim hrs_shape As Object
Dim hrs_obj As Object
Dim hrs_wb As Object
Dim hrs_ws As Object
Dim hrs_rng As Object

Set hrs_shape = objDoc.InlineShapes.AddChart(XlChartType.xlColumnClustered)
Set hrs_obj = hrs_shape.Chart

hrs_obj.ChartType = 51
hrs_obj.ChartData.Activate

Set hrs_wb = hrs_obj.ChartData.Workbook
Set hrs_ws = hrs_wb.Worksheets(1)

hrs_obj.SeriesCollection(3).Delete
hrs_obj.SeriesCollection(2).Delete
hrs_ws.Cells.Clear

hrs_ws.Range("A1").Value2 = "Quarter"
hrs_ws.Range("B1").Value2 = "Hours"
hrs_ws.Range("A2:A18").Value2 = quarterData
hrs_ws.Range("B2:B18").Value2 = hoursQtrData

Dim hrs_range As Range
Set hrs_range = hrs_ws.Range("A1:B18")
hrs_obj.SetSourceData Source:=hrs_range

End Sub

End Sub


r/vba 12d ago

Waiting on OP VB Errors When Running Macro in Excel

0 Upvotes

Hello,

I hope this is the right place for this. I'm supporting a user who relies on a macro-enabled Excel spreadsheet with multiple worksheets, but the key ones are:

  • Cost Items
  • Variables
  • Results Summary

The workflow:

  1. Enter data into the Cost Items sheet (e.g., Name: Test1, Cost: 1000; Name: test2, Cost: 5000).
  2. Add data to the Variables sheet under "Brisk Parameters" – P10: -5%, P90: 15%.
  3. Go to the Results Summary sheet.

At that point, I get a pop up message that states the data has changed.

I click OK, it churns for a moment, and then I get:

Microsoft Visual Basic - "Run-time error '9': Subscript out of range"

If I click Debug, it highlights this line in yellow:

"If VarExists(Count) And VarProb(I) = 1 Then"

What I've tried so far:

  • Searched online and found suggestions it might be an overflow error of some kind.
  • Tested on multiple systems (managed company device, unmanaged device, different PCs).
  • Confirmed Trust Center settings allow macros.
  • Installed and registered the Brisk server (was told this was required – still no change).

The kicker:
This exact file was working perfectly fine just a few weeks ago. No known changes were made to the file or the environment.

I've been banging my head against this for a couple of days now and am starting to lose my sanity.

Does anyone have any idea what direction I should go in to troubleshoot why this spreadsheet suddenly stopped functioning?

Any help would be greatly appreciated.

TIA!


r/vba 12d ago

Discussion Vba from multiple excels

1 Upvotes

I have multiple excel sheets. They have results from a scheme. Each excel has a sheet of how the performance is per month. There are 12 tabs of different values but the people in the scheme and the format are the same each month per sheet.

Is there a way to use VBA code to consolidate the data to change it from per month to per person, so if I use a drop down to select a person name, it will lift all the data for the previous 12 excel sheets and put them into 1 overview excel.

Also, is there a way then to make it generate graphs from a click of a button.

Finally, then could you export the graphs and tables to excel ?

I'm spending days doing it at the moment and there must be a simpler way.

I'm not sure if I'm talking garbage here but any help would be great.


r/vba 13d ago

Discussion Possible to Write a Macro between PowerPoint and Word

6 Upvotes

I wrote a macro that creates my metrics for me and it was the first one that I wrote that pastes data to PowePoint. So, that sort of gave me an idea for some other mundane tasks, which use PowerPoint. I take minutes for our customer meetings. I'm not a Stenographer, but I can type fast enough to get most things. The way it's currently setup, is that we have a word doc with a table and different rows for different slides.

Anyway, is it possible for a macro to take the slide# and some textbox text and put them in the same order in the word table? Or maybe put the data in excel and then word, which would seem like a useless workaround then doing the actual work?


r/vba 16d ago

Show & Tell Modern Json in VBA - v3.0.0 Released

16 Upvotes

Released earlier this year, ModernJsonInVBA parses JSON and writes it straight into Excel tables (ListObjects), and converts tables back to JSON roundtrip. It is pure VBA: no Scripting.Dictionary, no COM references, no external libraries. One call turns JSON text to a populated, refreshable table:

vba Excel_UpsertListObjectFromJsonAtRoot ws, "tOrders", ws.Range("A1"), jsonText, "$"

v3.0.0 split the engine into eleven modules and rewrote the parser and the Excel write path. I benchmarked it across seven payloads that vary in size and shape (flat rows, nested objects, escape-heavy strings, a 200-column wide table, numeric-heavy) and collected the results into a matrix.

Payloads

Payload Rows Cols Size
flat_10k 10,000 10 2.1 MB
nested_50k 50,000 9 9.2 MB
escapes_50k 50,000 6 14.8 MB
wide_5k_200c 5,000 200 16.0 MB
flat_100k 100,000 10 21.6 MB
numbers_200k 200,000 8 25.9 MB
flat_500k 500,000 10 109.5 MB

Timings (seconds) — rows are pipeline steps, columns are payloads:

Step flat_10k nested_50k escapes_50k wide_5k_200c flat_100k numbers_200k flat_500k
Read file 0.0273 0.0938 0.1523 0.1641 0.2227 0.2695 1.1289
Json_Parse (JSON to model) 0.2695 1.5586 1.3203 2.2344 2.3672 4.3984 11.8789
Json_Stringify (model to JSON) 0.2695 1.6719 1.4023 1.7266 2.5742 3.0430 12.9492
Upsert create (JSON to ListObject) 0.3281 2.4727 2.0625 2.8828 3.4727 4.7383 18.2656
Upsert refresh 0.3789 2.7422 2.3711 3.4844 3.9688 5.7305 20.3828
Export (ListObject to JSON) 0.1328 3.5195 0.9609 0.8477 1.3945 1.1484 7.1094

What the matrix shows:

  • 500,000 rows / 110 MB of JSON into a live Excel table in about 18 seconds (Upsert create). That is roughly 27,000 rows/sec, or ~275,000 cells/sec.
  • Small payloads are effectively instant: 10,000 rows loads in about a third of a second.
  • A raw block write of 5 million cells takes only a few seconds; most of the 18 s is parsing and shaping the JSON.
  • Upsert streams JSON straight into a 2D array for a root array (tableRoot = "$") and does not build an intermediate object model, so it keeps pace with a standalone parse plus a sheet write.

The benchmark machine is a Ryzen 7 9800X3D with 64-bit Excel, each cell is one wall-clock Timer run, and the payloads come from a seeded generator (deterministic). Times are hardware-dependent, so a typical office laptop will be slower. The whole table regenerates from the workbook with one macro (Run_JsonPerfMatrix), so you can produce your own numbers.

The library also does CSV and XML to JSON, JSONPath-style path resolution, schema evolution controls, and formula-preserving refreshes. Determinism is the design goal: stable column order, strict validation, and clear error numbers instead of silent guesses.

Repo (MIT): https://github.com/WilliamSmithEdward/ModernJsonInVBA

https://github.com/WilliamSmithEdward/ModernJsonInVBA/releases/tag/v3.0.0

Feedback is welcome.


r/vba 16d ago

Solved Permission denied vba error in Office 365

1 Upvotes

Within Windows 11 I have created a workbook with vba code in Excel 2019 and it works fine. Part of the code has a 'kill' statement which works fine in 2019 but when run in Office 365 Excel I get 'run time error 70 permission denied'.

I have been retired from IT for over 25 years and I know things have moved on but this has left me stumped.

Any assistance would be much appreciated.

Thank you

(I have not included any code but can do if required)


r/vba 17d ago

Solved How to use range.RemoveDuplicates in Excel VBA?

5 Upvotes

(Learned later that I should use [Excel] prefix in the title. Cannot edit title. But the information is there.)

In Excel VBA, I want to select a range (n rows, m columns) and remove duplicates.

The following works for 7 columns:

r.RemoveDuplicates Columns:=Array(1, 2, 3, 4, 5, 6, 7), Header:=xlYes

But I want it work with a variable number of columns.

I've tried the following. None works.

' Selection should be the upper-left corner (header row)
Set r = Range(Selection, Selection.End(xlDown).End(xlToRight))
r.Select

r.RemoveDuplicates
r.RemoveDuplicates Header:=xlYes

ncol = r.Columns.Count
ReDim dupecol(1 To ncol)
For i = 1 To ncol: dupecol(i) = i: Next
r.RemoveDuplicates Columns:=dupecol, Header:=xlYes
r.RemoveDuplicates Columns:=(dupecol), Header:=xlYes

The first two RemoveDuplicates simply do nothing (!).

The last code snippet results in error 5: invalid procedure call or argument in both cases.

I confirmed that r.Address, ncol, Typename(dupecol), dupecol(1) and dupecol(ncol) are what they should be.

Any idea how to make it work without using hardcoded Array(...)?

EDIT.... For testing purposes, I used the same conditions that worked with hardcoded Array(...). So, r.Address comprises only 7 columns, multiple rows and no adjacent data; ncol is 7; Typename(dupecol) is Variant(); LBound(dupecol) is 1 (\); UBound(dupecol) is 7; dupecol(1) is 1; and dupecol(ncol) is 7.*

(*) UPDATE.... As u/ZetaPower noted, LBound must be zero for it work with RemoveDuplicates Columns:=(dupecol). That is, it requires ReDim dupecol(0 to ncol-1).


r/vba 18d ago

Weekly Recap This Week's /r/VBA Recap for the week of June 27 - July 03, 2026

2 Upvotes

Saturday, June 27 - Friday, July 03, 2026

Top 5 Posts

score comments title & link
11 5 comments [Show & Tell] ChibiArc — ZIP, 7‑Zip, TAR, ISO support in 64‑bit VBA (AES included)
3 7 comments [Unsolved] [WORD] Range.FormattedText won't preserve font in last line of text
2 7 comments [Discussion] First time VBA user - Want all the dates i type in word to automatically be made into a timeline
2 7 comments [Solved] OneDrive won't sync .docx created from macro-enabled template (.dotm) found a "workaround" (re-triggering the file, sync starts) [WORD]
2 10 comments [Solved] Dynamically rename worksheets upon opening workbook

 

Top 5 Comments

score comment
3 /u/AvWxA said Don’t you have to add a ws.activate As the first line in your tabname sub?
2 /u/marlostanfield89 said Nice. Thanks Claude
2 /u/ZetaPower said Several issues in the code…. • there is a typo in Workbook/_Open • your variables have no upper/lower case combinations. Always use these, then type in lower case. As soon as you go to the nex...

 


r/vba 20d ago

Discussion First time VBA user - Want all the dates i type in word to automatically be made into a timeline

2 Upvotes

Hi all,

I am trying to write a personal compendium, sort of self-studying wikipedia document.

What i want the program to do is automatically detect dates written in a specific format (i prefer the 'Jan 01, 2000' format, but am not picky) sort them into chronological order, and list them into a master timeline underneath a header in the document. I would like each date in the timeline to link back to the original source within the document.

Is this something I can easily do?

I understand other programs will be more suitable for longterm goals and organisation, but it's too much of an undertaking to learn a whole new document program right now.


r/vba 21d ago

Solved OneDrive won't sync .docx created from macro-enabled template (.dotm) found a "workaround" (re-triggering the file, sync starts) [WORD]

3 Upvotes

Context: I was trying to make a template for my Uni so that I don't need to manually edit anything, but I ran into two issues which I kind-of Solved

Ms Word Ver: MS Word-365 (2026)
Windows Ver: Windows 10 Pro (Home would work too maybe)
OneDrive: Uni Acc. (Personal Would work too maybe)

Problem: File Not Auto-Syncing. Error: Macro Enabled, disabling it

Fix: Just click on the 'File' Section and it will Auto-Sync

EDIT: Actually.. you don't need to do any "rituals" for it to sync to OneDrive. Just start typing, and it automatically starts syncing

[How to use Macro/ .dotm Template]

Step 1: Make your template file first

Step 2: Save it as ".dotm" [Word will automatically save it at it's default position, re-open it and press Left-Alt + F11

Step 3: Double click on "ThisDocument" and paste the given macro with your formatting

Step 4: Save it 'CTRL+S' and exit everything, re-open word.

Step 5: Below the "Good Morning-etc." Greetings will be the template section, click on "More Templates" and head to "Personal" Section, Open the file and it should automatically save, Do the work-around I suggested.

Macro/ VBA Used:

    Dim srNo As String
    srNo = InputBox("Enter Experiment No.:", "New Document")
    ' Only Edit the "Enter Exp No.: " if needed.

    If srNo = "" Then Exit Sub

    Dim defaultName As String
    defaultName = "YourExpName" & srNo & "-YourID.docx"

    Dim saveFolder As String
    saveFolder = "OneDrive Folder Path"

    ' Since the post is for OneDrive Sync i.e One-Drive Path
    ' Create the folder if it doesn't exist yet
    If Dir(saveFolder, vbDirectory) = "" Then
        MkDir saveFolder
    End If

    ActiveDocument.SaveAs2 FileName:=saveFolder & defaultName, _         
       FileFormat:=wdFormatXMLDocumentPrivate Sub Document_New()
End Sub

If anyone has a better way to do it please comment on this post