A family of Microsoft relational database management systems designed for ease of use.
The following is a function I once wrote for multiple replacements:
Public Function MultiReplace(varInput, ParamArray varReplacements())
' call like this:
' MultiReplace("abcdefghijk","c","V","e","X","j","Y","m","Z")
' to return this:
' abVdXfghiYk
Const MESSAGETEXT = "Uneven number of replacements parameters."
Dim n As Integer
Dim varOutput As Variant
Dim intParamsCount As Integer
If Not IsNull(varInput) Then
intParamsCount = UBound(varReplacements) + 1
If intParamsCount Mod 2 = 0 Then
varOutput = varInput
For n = 0 To UBound(varReplacements) Step 2
varOutput = Replace(varOutput, varReplacements(n), varReplacements(n + 1))
Next n
Else
MsgBox MESSAGETEXT, vbExclamation, "Invalid Operation"
End If
End If
MultiReplace = varOutput
End Function
In your case you'd call it along these lines:
? MultiReplace("ab c#defg hijk"," ","","#","")
to replace spaces and the hash sign with zero length strings:
abcdefghijk
or you might want to remove hashes and replace spaces with underscore characters for instance:
? MultiReplace("ab c#defg hijk"," ","_","#","")
ab_cdefg_hijk