Can anyone help with this bit of code please?
With a string entered into a userform textbox, I'd like to replace any character that doesn't match one of the characters in 2 x arrays:
There are some errors with the Replace function and probably with the Arrays as well?
Thanks in advance.
With a string entered into a userform textbox, I'd like to replace any character that doesn't match one of the characters in 2 x arrays:
VBA Code:
Private Sub cmdRun_Click()
Dim Target As Variant
Dim Targarray1(0 - 9) As Integer
Dim Targarray2("+", "-", "(", ")", " ") As String
Target = txtbox.Value
For Each i In Len(Target)
If i <> Targarray1 Or i <> Targarray2 Then
Replace(Target,i,"")
End If
Next i
End Sub
There are some errors with the Replace function and probably with the Arrays as well?
Thanks in advance.