The command Replace()
does not work for me. I finally got it working but only by skipping over error messages. Why a command works with when there are errors, dont ask, here is my working code. Can anyone please explain where im going wrong?
If Target.Address(0, 0) = "E3" Then
Range("E3").Select
On Error Resume Next
Selection.NumberFormat = "@"
Selection.Replace What:="-", Replacement:=""
Selection.Replace What:=" ", Replacement:=""
Selection = UCase(Selection.Value)
End If
Also, why wouldn't something like this work?
selection.value = replace(selection.value," ", "")
A bit of context for those who want: I'm using this to remove " - " and spaces out of product style numbers automatically. eg 05402-pt072 004 needs to equal 05402pt072004.
Thanks to anyone who responds.