Skip to content

Instantly share code, notes, and snippets.

@ndthanh
Forked from spiridenok/gist:6154707
Created August 26, 2021 17:38
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
VBA: replace last occurrence of a string within a string
' replace only the LAST occurrence of a the SEARCH substring in SOURCE
' with the REPLACESTR string - search isn't case-sensitive
ReplaceLast = StrReverse(Replace(StrReverse(Source), StrReverse(Search), StrReverse(ReplaceStr), , 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment