Question posted 2011 · +25 upvotes
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
Accepted answer +44 upvotes
Use Access’s VBA function Replace(text, find, replacement):
Dim result As String
result = Replace("Some sentence containing Avenue in it.", "Avenue", "Ave")
Top vba Q&A (6)
- Difference between Visual Basic 6.0 and VBA +122 (2009)
- VBA – how to conditionally skip a for loop iteration +116 (2011)
- VBA: Test if string begins with a string? +53 (2013)
- html parsing of cricinfo scorecards +47 (2012)
- Code to loop through all records in MS Access +46 (2011)
- VBA Check if variable is empty +44 (2010)
vba solutions on this site
— top 7%.