Flora Edwards
asked on
Excel VBA search and replace a string
I need a code to search dashes - into a string and if found then replace it with space
how I can do that?
how I can do that?
ASKER
I know Subs formula. my question is on how to use the vba built in function "Replace" in VBA not in Built in function of Excel
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This is how you would use replace.
Dim strAString As String
strAString ="A-test-string"
MsgBox Replace(strAString, "-"," ")
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you guys
last query on this, if I want to replace dashes and underscores - & _ with space
how can this be done? does it require two times replace or ampersand can be used in replace?
last query on this, if I want to replace dashes and underscores - & _ with space
how can this be done? does it require two times replace or ampersand can be used in replace?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
two times replace..
=+SUBSTITUTE(A1;"-";" ")
Where A1 iscell with your data