The Problem (Q-score 25, ranked #6th of 95 in the VBA Core archive)
The scenario as originally posted in 2011
I am trying to create a piece of code that replaces one word with another.
Example: Replace Avenue with Ave and North with N.
I am using MS Access, I could use SQL REPLACE Function but I want to do this in VBA using Access module so that I can attached the function to other column.
I am not sure where to start with this, so any input will be greatly appreciated.
Guy
Why community consensus is tight on this one
Across 95 VBA Core entries in the archive, the accepted answer here holds elite answer (top 10 %%) status — meaning voters are unusually aligned on the right fix.
The Verified Solution — elite answer (top 10 %%) (+44)
4-line VBA Core pattern (copy-ready)
Use Access’s VBA function Replace(text, find, replacement):
Dim result As String
result = Replace("Some sentence containing Avenue in it.", "Avenue", "Ave")
When to Use It — vintage (14+ years old, pre-2013)
A top-10 VBA Core pattern — why it still holds up
Ranks #6th of 95 in the VBA Core archive. The only pattern ranked immediately above it is “html parsing of cricinfo scorecards” — compare both if you’re choosing between approaches.
What changed between 2011 and 2026
The answer is 15 years old. The VBA Core object model has been stable across Office 2013, 2016, 2019, 2021, 365, and 2024/2026 LTSC, so the pattern still compiles. Changes that might affect you: 64-bit API declarations (use PtrSafe), blocked macros in downloaded files (Mark-of-the-Web), and the shift toward Office Scripts for web-first workflows.