Question posted 2011 · +7 upvotes
I want to split a string with multiple delimeters using Excel VBA. One of the strings is:
d1-d2 d3 d4
We have a dash and a space as two delimeters. I tried the split function but it only does it with one delimeter.
Accepted answer +20 upvotes
You could first do a REPLACE on the string first and then do the split:
newString = Replace(origString, "-", " ")
newArray = SPlit(newString, " ")
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)
- Access VBA | How to replace parts of a string with another string +44 (2011)
vba solutions on this site
— top 23%.