Zhihar
Zhihar

Reputation: 1428

Replace several substrings to several substrings in single string using vba (excel)

please tell me whether it is possible to perform a replacement in a string that combines several different substitutions using VBA (excel)?

For example:

text = Replace(text, find1, res1)
text = Replace(text, find2, res2)

Real example:

text = Replace(text, " ", " ")
text = Replace(text, "&", "&")
text = Replace(text, "&lt", "<")

Maybe regexp?

Upvotes: 1

Views: 104

Answers (1)

Gary&#39;s Student
Gary&#39;s Student

Reputation: 96763

Nest them:

Text = Replace(Replace(Replace(Text, "&nbsp;", " "), "&amp;", "&"), "&lt", "<")

Upvotes: 1

Related Questions