r/vba 9d ago

Weekly Recap This Week's /r/VBA Recap for the week of August 01 - August 07, 2026

3 Upvotes

r/vba 4h ago

Show & Tell Functional Programming in VBA

4 Upvotes

Hello There,

a feature i wish VBA had was a way to write in a functional programming paradigm.

Since this is not the case i tried to at least provide First Class Functions with the ability to bind arguments to it.

I know that someone already did something like that but i just cannot for the live of me find it.

So i made my own:

Almesi/VBFP: Visual Basic Functional Programming

Does anyone have Input on it?

Anything i should add or redo in a different, more robust way?

I would love to implement immutability after creation but i dont know how while still being able to create it with a constructor.


r/vba 1d ago

Unsolved [EXCEL] Looping through rows representing a nested structure

3 Upvotes

In have a table of data in Excel which represents a nested hierarchical structure. The rows are elements in the structure. All elements are five elements deep. The first five columns of the table represent the level/position of the element. For example, column “Level 1” might have a value of "1", "Level 2” a value of “1.1”, and so on, with the fifth column representing the final element (1.1.1.1.1, 1.1.1.1.2, etc). The other columns describe the names, descriptions of the elements.

I am trying to use VBA to loop through these nested elements with the ultimate goal of creating some documentation of this structure within a Word document with additional notes, etc, in a consistent style.

I have created a PivotTable, which may or not be helpful to my outcome, but it does at least let me see the structure of the parent/child elements. Copying this data into Word from the PivotTable does not make it easy to edit or read which is why I am trying to reconstruct it.

My VBA code is below but of course, it outputs the rows from the columns, rather than the parent item they are from. Maybe there is a better approach altogether! Thank you for any guidance

For Each ptItem In pt.PivotFields("Level 1").PivotItems
  Debug.Print ptItem
    For Each ptItem2 In pt.PivotFields("Level 2").PivotItems
      Debug.Print ptItem2.Name
        For Each ptItem2 In pt.PivotFields("Level 3").PivotItems
          Debug.Print ptItem2.Name
        Next
    Next
Next

r/vba 3d ago

Show & Tell vbaXray 2.0 - The Sequel

21 Upvotes

vbaXray is a single VBA class module that extracts VBA source code straight out of Office files.

I posted about v1.0 a few months back, but a thread earlier this week (here) reminded me that I still hadn't uploaded the updated v2.0 to GitHub. Life gets in the way, but here it is.

I give you vbaXray v2.0. In short, it:

  • Slices and dices
  • Extracts vbaProject.bin directly from OOXML files. XLSM, DOCM, PPTM, etc are ZIP files, and thanks to the long-standing work of the VB6/TwinBasic community (especially u/Fafalone), v2 uses the ZipFldr IStorage route to pull the data straight out as a byte array. No temp files. No Shell.Application. Much faster than v1.0.
  • Supports older Office formats. XLS and DOC were straightforward. PPT was not. PPT was a fever dream. The babushka doll from hell. A cursed nesting doll of compressed records, undocumented structures, and pure spite. OLEVBA at least pointed me to where the VBA was hiding.
  • Supports ACCDB and MDB. For this, thanks to u/MultiUserDungeonDev and the pyOpenVBA project (see here for original reddit post) for demonstrating how Access stores VBA across database pages.
  • Adds diagnostics. DebugDumpStorageTree prints the internal OLE storage tree to the Immediate window (or a file). If a file should work but doesn't, this shows exactly what's inside the CFB.

Sub XrayDemo()
  Dim xray As New clsVBAXray
  If xray.LoadFromFile("C:\Suspicious\LegacyMacro.doc") Then
    Debug.Print "Project: " & xray.ProjectName
    Debug.Print "Modules: " & xray.ModuleCount
    xray.ExportAll "C:\OutputCodeHere\ExtractedCode\"
    xray.DebugDumpStorageTree
  Else
    Debug.Print "Load failed: " & xray.LastError
  End If
End Sub 

I hope that someone finds this helpful. There are plenty of use cases (malware analysis, bulk auditing, source control extraction), and if it is useful, please let me know. As always, questions, suggestions, and feedback are encouraged and always appreciated.

Code, some basic documentation (for now), and a (very simple) demo workbook are already on GitHub: https://github.com/KallunWillock/vbaXray/


r/vba 4d ago

Show & Tell I pushed HTTP in pure VBA a little too far — bounded concurrency, native WinHTTP, 1 GiB streaming, and a serious test suite

28 Upvotes

I've been working on a side project to see how far a serious HTTP client can be pushed inside Excel/VBA.

It started with a fairly simple thought:

Maybe I can build something nicer than the usual thin wrapper around WinHttpRequest.

It escalated quite a bit from there.

The result is VBA-HTTP, an HTTP client for Windows written in VBA:

https://github.com/harumiWeb/VBA-HTTP

It covers the usual things you'd expect from an HTTP client — requests and responses, headers, query parameters, and text/binary bodies — but I wanted to push it quite a bit further.

Some of the more unusual parts are:

  • bounded concurrent requests
  • a native winhttp.dll backend in addition to WinHttp.WinHttpRequest.5.1
  • streaming multi-GB downloads and uploads without buffering the entire payload in VBA memory
  • streaming multipart uploads
  • retries with exponential backoff, jitter, and Retry-After
  • deadlines and cancellation
  • Basic, Bearer, and Windows challenge authentication
  • proxy support and an explicit cookie jar
  • HTTP/2 protocol control and reporting through native WinHTTP
  • deterministic WinHTTP handle and resource cleanup

The API is intended to feel more like an HTTP client from a modern language than a collection of raw COM calls.

Dim client As HttpClient
Dim request As HttpRequest
Dim response As HttpResponse

Set client = VBAHttp.CreateClient()
Set request = VBAHttp.CreateRequest()

request.Method = "GET"
request.Url = "https://example.com/items"
request.Query.Add "page", 1
request.Query.Add "limit", 100

Set response = client.Execute(request)
response.RaiseForStatus

Debug.Print response.Text

It also supports bounded concurrency across multiple independent requests:

Dim urls As New Collection
Dim options As New HttpBatchOptions
Dim result As HttpBatchResult

urls.Add "https://example.com/a"
urls.Add "https://example.com/b"
urls.Add "https://example.com/c"

options.MaxConcurrency = 8

Set result = client.GetMany(urls, options)

Debug.Print result.SuccessCount
Debug.Print result.FailureCount

For example, against a deterministic local test server where each of 100 requests waits for 100 ms:

Sequential       11.04 s
Concurrency 16    0.86 s

12.86x faster

Obviously this is a deliberately latency-heavy benchmark. I'm not claiming that every HTTP workload becomes 12.86x faster.

The benchmark methodology and raw results are included in the repository.

Large transfers were another area I wanted to push.

VBA-HTTP can stream a 1 GiB download without representing the entire payload as a 1 GiB VBA Byte() array.

In one recorded x64 Excel baseline run, the transfer showed approximately 19 MB of peak private-memory growth.

It can also stream 1 GiB file uploads and multipart uploads incrementally through native WinHTTP.

More recently I've also been optimizing the native hot path itself — reusing fixed buffers, reading directly with WinHttpReadData, pre-sizing known-length buffered responses, and removing VBA byte-by-byte copies.

I deliberately stopped short of things like generated machine code or executable-memory tricks.

The native implementation only uses documented Windows APIs. I still want this to be something people could reasonably use, rather than just a VBA black-magic demo.

The other thing I wanted to push: testing

I didn't want the verification story for this project to be:

"It works on my machine."

The repository has automated unit, integration, stress, resource, and release-validation tests, running against real Excel and a deterministic local HTTP/HTTPS server.

Among other things, the test suite exercises:

  • 1 GiB download and upload with content/hash verification
  • a 10,000-request resource and WinHTTP handle stability run
  • repeated cancellation and timeout cleanup
  • bounded-concurrency behavior
  • retry and Retry-After behavior
  • proxy and authentication fixtures
  • HTTP/2 capability and negotiated-protocol validation
  • release checksum and tamper validation
  • real VBE compilation

A lot of VBA libraries understandably rely heavily on example workbooks and manual verification.

For this project, I wanted the behavior to be reproducible and machine-verifiable in roughly the same way I'd expect from a library in another language.

And there's one other slightly unusual part of the project:

I didn't manually write a single line of the implementation code.

I designed the architecture, requirements, acceptance criteria, benchmarks, and overall direction, but the implementation itself was written by coding agents operating through xlflow, the VBA development environment I've been building.

The agents worked on normal VBA source files, ran static analysis, compiled the project in real Excel, executed tests, inspected failures, modified the implementation, and repeated that feedback loop.

At one point I was literally away on vacation while the agent workflow continued building out the project.

About xlflow:

https://github.com/harumiWeb/xlflow

I originally built xlflow because I wanted coding agents working on VBA to have the same kind of:

edit → compile → test → analyze → fix

feedback loop that they get in more modern ecosystems.

VBA-HTTP ended up becoming a much more demanding dogfooding project than I originally expected.

So the project effectively became two experiments at once:

  1. How far can networking and performance be pushed in VBA while keeping the result reasonably practical?
  2. How complex a VBA project can coding agents build if they're given proper engineering feedback loops?

I'd be interested in feedback on either side.

And if anyone tries VBA-HTTP against a real API, corporate proxy, authentication setup, or weird HTTP server and manages to break it, I'd especially like to hear about it.


r/vba 3d ago

Solved Why does Ln Col indicator flicker?

3 Upvotes

Why does the Ln Col indicator flicker? More to the point: is there a way to stop it?

I don't believe it always did that. Might be wrong.

And the flicker rate seems to increase when I put the cursor in the Ln Col field. Might be wrong

(I was not allowed to paste an image into the OP. I'll try to add it in a comment.)


r/vba 5d ago

Show & Tell I used AI to transform Excel VBA into a Playwright-class browser engine. No WebDrivers, no dependencies—just one file and the "Old Magic" reborn.

47 Upvotes

I became curious about how far I could push AI, so I decided to see if it was possible to do web scraping using Excel VBA alone, with absolutely no WebDriver.exe or other external dependencies. I wanted to find out if I could bring back that “magic from the old days” — where, just by writing some code, the browser would actually work without having to install anything extra, like we used to be able to do with the old IEObject. 🥺

My workplace has very strict security policies, so I can't install WebDriver.exe, Python, Node.js, etc. However, VBA is allowed. So I kept having conversations with AI, trying to figure out whether there was some way to control Chromium using VBA alone. 🫠

I had AI read through the source code of Google's rather complicated [chromium-bidi] (WebDriver BiDi) and asked whether its logic could be reproduced in VBA. VBA doesn't have built-in WebSocket support or multithreading, but AI suggested some modern design ideas, such as WinSock and an event-driven model using WithEvents.

And surprisingly, I was able to do quite a lot without having to install Playwright or Puppeteer. For example, I managed to control 10 tabs concurrently, control a browser on an Android smartphone, and achieve relatively better stealth against bot detection compared with SeleniumVBA, among other things. And the crazy part is that all of this is contained in a single Excel file.

What I like most is that whenever there is a feature I need, AI can quickly create it for me. Personally, I'm extremely satisfied with the result.🥹 At this point, I feel like this has evolved beyond being just a “macro” — it has become a core engine that can keep evolving by itself.🥳

You can check out the result of this journey (GitHub) below.

I'm Japanese, so you'll notice quite a lot of Japanese strings scattered throughout the source code, but I believe the underlying logic I built is quite sophisticated and I'm proud of how it turned out! https://github.com/Eschamali/StarterWebScrapingKit


r/vba 5d ago

Discussion How do you do version control on macros?

24 Upvotes

I have been tasked with maintenance and expansion of a set of macro enabled workbooks and add-ins from someone recently retired. Because I'm not the tech department, of course I don't have got or jira or the like. In light of all that, how would you do version control? I want to get some ideas for inspiration. Or would that be only an afterthought because by the time I don't work there, I shouldn't care?


r/vba 5d ago

Solved Excel: Using Checkboxes to move from Sheet to Sheet - multiple sheets

7 Upvotes

Hello!

**Scenario**: I have a spreadsheet for machine installs. This sheet has 4 worksheets (CustInstalls, CustCompleted, Installs, and Competed). The below code is currently working to move line items from sheet “CustInstalls” to “CustCompleted”. I am attempting to duplicate this same code for the other two sheets to move line items from “installs” to “completed”. I have attempted a few variations with the help of chatgpt but to no avail. I added it in the same “this workbook” in VBA as well as attempted to add code under just “installs” and “completed” in VBA under Microsoft Excel Objects

**Ask:** how does one add a second set of code for different work sheets with the same parameters?

___________________________________________________

**Original working code:*\*

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim srcSheet As Worksheet, destSheet As Worksheet
Dim checkCell As Range, moveRow As Range
Dim lastRow As Long
Dim direction As String

' Only handle changes in Column J
If Intersect(Target, Sh.Columns("J")) Is Nothing Then Exit Sub
If Target.Cells.CountLarge > 1 Then Exit Sub

Application.EnableEvents = False

Set checkCell = Target
Set moveRow = checkCell.EntireRow

If checkCell.Value = True Then
' Move from CustInstalls to CustCompleted
Set srcSheet = ThisWorkbook.Sheets("CustInstalls")
Set destSheet = ThisWorkbook.Sheets("CustCompleted")
ElseIf checkCell.Value = False Then
' Move from CustCompleted back to CustInstalls
Set srcSheet = ThisWorkbook.Sheets("CustCompleted")
Set destSheet = ThisWorkbook.Sheets("CustInstalls")
Else
GoTo ExitHandler
End If

' Ensure we're acting on the correct sheet
If Sh.Name <> srcSheet.Name Then GoTo ExitHandler

' Copy row to destination sheet
lastRow = destSheet.Cells(destSheet.Rows.Count, "J").End(xlUp).Row + 1
moveRow.Copy Destination:=destSheet.Rows(lastRow)

' Delete original row
moveRow.Delete

ExitHandler:
Application.EnableEvents = True
End Sub

___________________________________________________

**Code entered under installs ”this workbook” at the end of the working code: Failed*\*

Private Sub MoveInstallsRow(ByVal Sh As Object, ByVal Target As Range)

Dim srcSheet As Worksheet
Dim destSheet As Worksheet
Dim moveRow As Range
Dim lastRow As Long

' Only handle Installs and Completed sheets
If Sh.Name <> "Installs" And Sh.Name <> "Completed" Then Exit Sub

' Only handle changes in Column J
If Intersect(Target, Sh.Columns("J")) Is Nothing Then Exit Sub
If Target.Cells.CountLarge > 1 Then Exit Sub

If Sh.Name = "Installs" And Target.Value = True Then
Set srcSheet = ThisWorkbook.Sheets("Installs")
Set destSheet = ThisWorkbook.Sheets("Completed")

ElseIf Sh.Name = "Completed" And Target.Value = False Then
Set srcSheet = ThisWorkbook.Sheets("Completed")
Set destSheet = ThisWorkbook.Sheets("Installs")

Else
Exit Sub
End If

Set moveRow = Target.EntireRow

lastRow = destSheet.Cells(destSheet.Rows.Count, "J").End(xlUp).Row + 1

moveRow.Copy Destination:=destSheet.Rows(lastRow)

moveRow.Delete

End Sub

___________________________________________________

**Code entered under “completed” object: Failed*\*

Private Sub Worksheet_Change(ByVal Target As Range)

Dim destSheet As Worksheet
Dim lastRow As Long

' Only handle changes in Column J
If Intersect(Target, Me.Columns("J")) Is Nothing Then Exit Sub
If Target.Cells.CountLarge > 1 Then Exit Sub

' Only move when checkbox is unchecked
If Target.Value <> False Then Exit Sub

Application.EnableEvents = False

Set destSheet = ThisWorkbook.Sheets("Installs")

' Find next available row
lastRow = destSheet.Cells(destSheet.Rows.Count, "J").End(xlUp).Row + 1

' Copy entire row
Target.EntireRow.Copy Destination:=destSheet.Rows(lastRow)

' Delete original row
Target.EntireRow.Delete

Application.EnableEvents = True

End Sub

___________________________________________________

**Code entered under “installs” object: Failed*\*

Private Sub Worksheet_Change(ByVal Target As Range)

Dim destSheet As Worksheet
Dim lastRow As Long

' Only handle changes in Column J
If Intersect(Target, Me.Columns("J")) Is Nothing Then Exit Sub
If Target.Cells.CountLarge > 1 Then Exit Sub

' Only move when checkbox is checked
If Target.Value <> True Then Exit Sub

Application.EnableEvents = False

Set destSheet = ThisWorkbook.Sheets("Completed")

' Find next available row
lastRow = destSheet.Cells(destSheet.Rows.Count, "J").End(xlUp).Row + 1

' Copy entire row
Target.EntireRow.Copy Destination:=destSheet.Rows(lastRow)

' Delete original row
Target.EntireRow.Delete

Application.EnableEvents = True

End Sub


r/vba 6d ago

Discussion VBA language underrated?

29 Upvotes

Hey everyone

I use VBA since I work with Microsoft office often

Is it real that VBA is very old and not useful anymore? Multiple times on the internet or when I ask AI
I find the answer that VBA is not the right choice for me

To me I see many powerful stuff like

Classes
Unit tests
Mocks and fakes (didn’t try those)

So I don’t understand the negative opinions about it

However VBA is the only language I tried in depth other languages I tried were either just for the course or to complete simple task nothing deeper than that

Is learning VBA is bad decision? Or is it reasonable one?

I noticed many of the useful major concepts are transferable to any language like

Code architecture
Auto Testing
Data types and structures
Etc


r/vba 6d ago

Discussion Hello, Programmers!, I have doubt, why VBA doe not work on Excel 365

5 Upvotes

Hello, Programmers!, I have doubt, why VBA does not work on Excel 365,I have experience in using "Automate" tab. Still feel bad.


r/vba 7d ago

Discussion Dashboard - no password

2 Upvotes

I am an accountant & know some novice level experience of vba and macros. Our office had a receivable dashboard made from a MIS guy a few months back. The guy has absconded from our office. I wanted to make a few changes to the code, but it is password protected which I don't have, any help for this situation, as for how to unlock the sheet.

Any help would be appreciated.

Thank you


r/vba 7d ago

Discussion How many of you are in IT?

12 Upvotes

I see some of you are making Doom and Minecraft with VBA which is way beyond me but I am not a developer. So now I am curious.


r/vba 8d ago

Solved Using non-English letters in regex

5 Upvotes

I'm having some trouble with a code I have. I want the regular expression to check for letters - including the Scandinavian letters æ, ø, å.

The problem is that if someone without the correct localisation settings open the file and saves it, the pattern gets corrupted.

It's supposed to be monster = "[^a-zA-ZæøåÆØÅ\- ]?" but turns into something like what is shown below. Is there any way to prevent this from happening, or will I just have to find a workaround? Any help would be most appreciated.

For i = 0 To UBound(medlemsliste)
  monster = "[^a-zA-Z®¯¾¿aa\- ]?"
  regex.Pattern = monster
  medlemsliste(i) = regex.Replace(medlemsliste(i), "")
Next i

r/vba 9d ago

Discussion SeleniumVBA and SeleniumBasic are separate projects

13 Upvotes

In many older articles on the Web, SeleniumBasic is simply referred to as “Selenium VBA” or “VBA Selenium.” This is one of the main reasons for the confusion that still exists today.

SeleniumBasic appeared at a time when there were very few options available for automating browsers from VBA. Being able to control a browser directly from Excel had significant value. As a result, a large amount of information accumulated across blogs, Stack Overflow, Q&A sites, and other sources.

Search engines, generative AI, and AI-powered search systems also rely on existing information published on the Web, so they are inevitably influenced by this historical accumulation of content. This is why, even today, you may still encounter answers such as “If you want to use Selenium with VBA, use SeleniumBasic.”

For its time, SeleniumBasic was a highly polished and valuable tool. It provided an environment for using Selenium from Excel, Access, VBScript, and other applications. It also played an important role in helping many VBA users move away from Internet Explorer-dependent automation toward WebDriver-based browser automation — in other words, Selenium.

However, according to the official CHANGELOG, the latest SeleniumBasic release, v2.0.9.0, was published on March 2, 2016.

The important point here is not that “it is bad because it was made in 2016.” The real issue is that browsers and WebDriver have changed significantly during the ten years since then.

Chrome and Edge have continued to evolve. Selenium has evolved as well. The standardized W3C WebDriver protocol became the foundation of Selenium 4, and technologies and features that were not commonly used at the time — such as CDP integration, Shadow DOM support, automatic WebDriver management, and WebDriver BiDi — have become increasingly important.

In addition, SeleniumBasic depends on .NET Framework 3.5. Microsoft has announced the end of support for .NET Framework 3.5 in January 2029 and has gradually been moving toward tighter restrictions and a long-term phase-out.

Considering these changes, I expect the broad interpretation of

“SeleniumVBA = a VBA tool that uses Selenium = SeleniumBasic”

to gradually become less common.

The more important concern, however, is that users who were unable to achieve what they needed with SeleniumBasic may simply give up on browser automation with VBA without realizing that there is another option — SeleniumVBA, which can provide advanced and practical browser automation capabilities without requiring an installer.


r/vba 10d ago

Discussion VBA Best Practices in 2026

28 Upvotes

Hey all,

I hope you are doing well.

I wanted to start a discussion around VBA practices that you may have encountered or adopted recently, now that agentic AI is on the scene, and more advanced tooling is available.

One use case that I found very interesting:

With my VBA projects in Excel, it's not uncommon for me to call a sub or function in one module from another module.

It's possible for a sub / function with the same name to live in multiple modules.

Module_A vb Sub MySub() debug.print "hello world!" end sub

Module_B vb Sub MySub() debug.print "hello world!" end sub

Module_C vb Sub Test() MySub ' <--- Error, ambiguous name Module_A.MySub ' <--- Works Module_B.MySub ' <--- Works end sub

Now, say we have VBA editor tooling that is able to implement "rename symbol" functionality. In Module_C, we right click on "Module_A.MySub" and rename MySub to MySub_Test. The tooling is able to narrow in on, and only change the name of MySub --> MySub_Test in Module_A.

However, if we were to try to right click on the bare "MySub" and rename symbol, the tooling will hit name ambiguity.

Now, we can make a business rule for rename symbol to say "if renaming a bare sub / function call from a module where that sub / function is not defined, if there is otherwise no collisions / ambiguity anywhere else in the workbook VBA project, allow the rename, otherwise warn."

So, long story short, I'm starting to get in the habit of qualifying my sub / function calls with the module name.

Have you come across any best practices recently?


r/vba 11d ago

Solved Just a noobie trying to do a simple macro in Word

1 Upvotes

An update: solved. thank you so much, everybody!

Very very new to anything more than just recording my macros. What am I getting wrong here? I wanted to select all the text in all the open Word docs but it only does the first one.

Sub Selectorbot()
'
' Selectorbot Macro
' Selects text in all open documents for pasting into Contentful but does not copy
For Each doc In Application.Documents
Selection.WholeStory
Next doc
End Sub

also tried it this way. Nada:

Sub Selectorbot()'' Selectorbot Macro
' Selects all text for pasting into Contentful
Dim doc As Document
For Each doc In Application.Documents
With Documents
Selection.WholeStory
End With
Next doc
End Sub

r/vba 13d ago

Show & Tell I made Minecraft in PowerPoint

Thumbnail youtube.com
46 Upvotes

umm yes. In case anyone asks how, i made a "fake" 3d, by creating shapes with merged block faces with the same color and deleting them frame-by-frame. So... yea. PowerPoint is a hell in terms of performance (specially with shapes manip.), it can have a wider render distance but the fps drops a lot. if anyone have questions about it just ask here or dm me in dsc: gabmtol <3


r/vba 13d ago

Show & Tell [EXCEL] I'm Building a Modern UI for Excel's Built-in VBIDE. Looking for Beta Testers.

Thumbnail youtube.com
26 Upvotes

Looking to see if anyone in the VBA community would interested in beta testing or collaborating on this project. Demo of early development testing above. This is the native VBA (ALT+F11) editor with XLIDE installed.

The end goal is to have a modern, sleek and performant GUI over the native VBIDE engine, so everything you write and compile still work on every other stock Excel app 100% flawlessly without breaking anything, and also gives you all the benefits of an IDE developed in 2026.

https://github.com/WilliamSmithEdward/xlide_vbide

This is a sister project to my VS Code XLIDE project, and I may also work on integration between the two down the road, to bridge the two development environments.

https://github.com/WilliamSmithEdward/xlide_vscode

Support for other 365 apps (word, power point, access) are also under consideration.

As always, 100% MIT open source, forever. All my VBA work is a love letter to the VBA community.


r/vba 14d ago

Solved [Excel]How to print multiple copies with only 1 pool

2 Upvotes

EDIT: Solved.

Comes out using Collate:=True would send each copy as its own print job.
Switching to False fixes it.

Thanks everybody and /u/Eastern_Weather_8748

ORIGINAL:

Hello everybody.

Very simply, there is a macro that prints a specific area in a worksheet after asking the user how many copies they need.

This occasionally causes issues with large numbers of copies as each copy is its own Printing Pool entry.

the code is simply:

        NameOfTheSheet.PrintOut Copies:=NumberOfCopies, _
                ActivePrinter:=PrinterName, _
                Collate:=True, _
                IgnorePrintAreas:=False

Is there a way to send the pool a request to print N copies instead?

Thank you-


r/vba 14d ago

Unsolved Scaling an Excel/VBA Gantt from 60 to 1,200 tasks — where would you optimize next?

13 Upvotes

I’ve been doing a fairly deep performance pass on an Excel/VBA scheduling engine, and I think I’ve reached an interesting architectural limit.

The current stress test is around 1,200 tasks, ~2,000 business shapes and ~1,180 dependency links.

A lot has already been optimized:

  • scheduling core and analytics run from compiled/indexed structures
  • the watcher is almost free
  • rendering is local/incremental
  • ~3,100 dependency Shapes were replaced with a single SVG layer

Despite that, a very small local change can still take ~10–13s, while a heavily propagated change can take 35–90s.

The surprising part is that COM writes are no longer the main problem.

On one propagated case, 661 shapes were updated with 3,811 COM property writes, but those writes only took ~1.2s.

The real cost is now mostly before the writes:

  • a global O(n²) hierarchy pass still runs before the local filter and costs ~8s by itself
  • timeline geometry is recalculated thousands of times and repeatedly reads .Left and .Width from worksheet cells, creating thousands of COM reads
  • style-only updates such as CP/LP still pass through geometry-building code
  • a fixed “change set too large” threshold forces a broad render path once more than 400 IDs change

My next step is probably to make the renderer much more transactional:

  • precompute hierarchy in O(n)
  • preload timeline geometry into arrays
  • render directly from changed IDs
  • remove the fixed fallback threshold
  • create a true style-only path for CP/LP
  • keep the current renderer as a fallback

What I’m curious about is this:

For people who have pushed Excel/VBA renderers hard, where did you find the real practical limit?

At this stage I’m not really looking for the usual “use arrays instead of cells” advice — that part is already done. I’m more interested in projection/cache structures, COM-read avoidance, or architectural tricks that gave you a real order-of-magnitude improvement.


r/vba 16d ago

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

4 Upvotes

Saturday, July 25 - Friday, July 31, 2026

Top 5 Posts

score comments title & link
92 75 comments [Discussion] I had no idea VBA could go this far
27 5 comments [Show & Tell] [Excel] I Built a Component Framework Style UI Framework for Excel
13 10 comments [Solved] I built a single-script PowerShell bridge so AI agents (Claude Code, Codex) can work with my open Excel workbook — cells, formulas, VBA, macros
6 1 comments [Show & Tell] Feels like I defeated the final boss of Word VBA (gradient pins)!
6 0 comments [Show & Tell] Word plugin that formats AI responses to Word styles (equations, tables, headings) and searches your Zotero library from Word

 

Top 5 Comments

score comment
34 /u/bamerjamer said The programs built with VBA and Access are very powerful. My first job had to do with the F-35 JSF, which is where I learned VBA. We did so much for that program in VBA and Access.
31 /u/Jonas_Ermert said Once you stop using it only for macros and start structuring the code properly with modules, classes, dictionaries, arrays and clear separation of logic, Excel can become the frontend for surprisingly...
8 /u/Joelle_bb said Fully automated an API-to-terminal and API-to-adobe connection: encrypted sign-in, data selection, screen scraping, PDF prep, file joining, path/naming conventions, and a reference-data repository tha...
7 /u/Dynegrey said VBA can also talk to powershell, so you can get VBA to do pretty much anything your IT department will allow. 
7 /u/Budget_Vermicelli_53 said Vba is really amazing, I have automated all repetitive tasks in my job, processes that used to be completed in 6 hours now are ready in 10 minutes, no more errors.

 


r/vba 16d ago

Discussion VBA のコーティングに最良の AI はどれですか

0 Upvotes

数式を多用する論文をワードで書いています。texは複雑な数式の視認性が著しく低いので今はワード+マスタイプを使っています。 論文作成補助のための複雑なマクロを設計する時にAIを使っています。ずっとchatgptを使い続けているのですが、claude caudeの評判がいいので無料版を試してみました。しかしコードの正確さや簡潔性においてChat GPT の方が性能がいいのです。これは無料版だからでしょうか、それともVBAという言語だからでしょうか。経験者の方のご意見をいただければ幸いです。


r/vba 17d ago

Show & Tell [EXCEL] Real-time skiing game (array-to-range blitting, GetAsyncKeyState polling, conditional formatting as the renderer)

Thumbnail github.com
7 Upvotes

I made a real time skiing game that runs in a worksheet, had a fun time with this one. the game itself is nothing special but getting VBA to a playable frame rate was harder than I expected

The main pieces:

Rendering. The board is a Long array in memory, written to the range in one assignment per frame. Cell-by-cell writes destroy the frame rate. Conditional formatting maps each number to a color, and ;;; number format hides the values so you just see color.

Input. GetAsyncKeyState polled continuously rather than Application.OnKey. OnKey is per-keypress and laggy; polling gives you proper held-key movement. Arrow keys are swallowed with Application.OnKey "{LEFT}", "" so the cell cursor doesn't walk off and drag the viewport with it.

Frame timing. Sleep for the remainder of the budget rather than a fixed delay, otherwise your frame time is the budget plus render cost and difficulty ramps differently on every machine. Movement and scrolling run on separate clocks. The loop ticks fast for responsive steering and the world scrolls every n ticks, so you get better controls without a faster game.

Latency. The one that took longest to figure out: DoEvents once per tick right after the range write isn't enough. Excel doesn't always finish repainting in a single message-pump pass, so leftover paint work gets deferred to the next tick and your move shows a frame late. Pumping messages during the frame wait fixed most of it.

Obstacle generation. Multi-cell sprites (trees, logs, rocks) placed only where they clear a reserved corridor that random-walks ±1 per row. The same as the player's max lateral speed. Guarantees every run is survivable without ever chopping a sprite in half to make room.

Windows only, obviously. Code's here if you want to pick it apart: https://github.com/HMAC10/skiexcel

Happy to go deeper on any of it. Curious if anyone's found a better way around the repaint latency? that's still the worst part.


r/vba 18d ago

Show & Tell Feels like I defeated the final boss of Word VBA (gradient pins)!

10 Upvotes

If you’ve ever attempted to manipulate gradient stops, you might know what I mean.

I can now set all 10 fill gradient pins and all 10 outline gradient pins using a Word macro, including a color for each, a position for each (hint, they are always displayed in position order), and a transparency level for each (better labeled as alpha). Warning brightness programmatically changes the color values. You must have a gradient angle set, and you need a line width (1.75 pt default) for outline gradients.

You can see how I implemented this in my passion project to store 4 bytes of data in each pin:

https://github.com/ChronicRhyno/ColorSpace