Vba Replace

[Solved] Vba Replace | Vb - Code Explorer | yomemimo.com
Question : vba replace

Answered by : vastemonde

' Replace into string
Sub TestMe() Debug.Print Replace("a,B,c,d,e", ",", "-") 'a,B,c,d,e -> a-B-c-d-e Debug.Print Replace("Mr XXX", "XXX", "Bond") 'Mr XXX -> Mr Bond Debug.Print Replace("a,b,c,d,e", ",", "-", 3, 2) 'a,B,c,d,e -> b-c-d,e
End Sub

Source : | Last Update : Sun, 31 Jan 21

Question : excel vba replace part of a string

Answered by : daniel-ferry

'VBA function to replace a substring... if it exists in the full
'string. Checking to see if it exists is very quick. Replacing is
'slow by comparison. So it is wise to check first:
Function IfInReplace$(s$, substr1$, replacement$, Optional CaseSensitivity = vbTextCompare) If InStr(1, s, substr1, CaseSensitivity) Then s = Replace(s, substr1, replacement, , , CaseSensitivity) IfInReplace = s
End Function
'---------------------------------------------------------------------------------------------------
MsgBox IfInReplace("abc123def", "123", "") '<--displays: abcdef

Source : http://academy.excelhero.com/ | Last Update : Mon, 11 May 20

Answers related to vba replace

Code Explorer Popular Question For Vb