title: VBA code to find and replace using maybe wildcard?
body: <p>How can I find and remove X from strings, in other words, replace NX1 with N1, NX2 with N2, NX7535 with N7535, all strings start with N but not all have X after N, if they do I need to remove that X, Below I put crazy code I adapted from excel recording but it has to be easier way to do it:    </p>
  
  <pre><code>   Sub Find_NX_Replace()
  
  
  
       Range("A1").Select
       Range(Selection, Selection.End(xlDown)).Select
       Selection.Replace What:="NX1", Replacement:="N1", LookAt:=xlPart, _
      SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
      ReplaceFormat:=False
  
      Selection.Replace What:="NX2", Replacement:="N2", LookAt:=xlPart, _
      SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
      ReplaceFormat:=False
  
       Selection.Replace What:="NX3", Replacement:="N3", LookAt:=xlPart, _
      SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
      ReplaceFormat:=False
  
   Selection.Replace What:="NX4", Replacement:="N4", LookAt:=xlPart, _
      SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
      ReplaceFormat:=False
  
       Selection.Replace What:="NX5", Replacement:="N5", LookAt:=xlPart, _
      SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
      ReplaceFormat:=False
  
      Selection.Replace What:="NX6", Replacement:="N6", LookAt:=xlPart, _
      SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
      ReplaceFormat:=False
  
       Selection.Replace What:="NX7", Replacement:="N7", LookAt:=xlPart, _
      SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
      ReplaceFormat:=False
  
      Selection.Replace What:="NX8", Replacement:="N8", LookAt:=xlPart, _
      SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
      ReplaceFormat:=False
  
  
       Selection.Replace What:="NX9", Replacement:="N9", LookAt:=xlPart, _
      SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
      ReplaceFormat:=False
  
  
  
  
     End Sub
  </code></pre>
  
  <p>Example:</p>
  
  <p><a href="https://i.stack.imgur.com/YNcOx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YNcOx.jpg" alt="enter image description here"></a></p>