title: VBA Replace() not working
body: <p>The command <code>Replace()</code> 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?</p>
  
  <pre><code>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
  </code></pre>
  
  <p>Also, why wouldn't something like this work?</p>
  
  <pre><code>selection.value = replace(selection.value," ", "")
  </code></pre>
  
  <p>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.</p>
  
  <p>Thanks to anyone who responds.</p>