title: VBA: Function to remove all special characters
body: <p>I've done some searching for a solution to this and I've not been able to find something I can use directly.  Therefore, by trying to edit someone else's code for my own use, I've come to an issue.</p>
  
  <p>I'm trying to use the line <code>RemoveSpecialChars("$C$1")</code> but I get an <code>Object required</code> error.</p>
  
  <p>The function is as follows:</p>
  
  <pre><code>Function RemoveSpecialChars(ByVal mfr As Range)
  
      Const splChars As String = "!@#$%^&amp;()/"
      Dim ch As Characters
  
      For Each ch In splChars
      mfr.Replace What:=ch, Replacement:="", LookAt:=xlPart, _
                  SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
                  ReplaceFormat:=False
      Next ch
  
  End Function
  </code></pre>
  
  <p>This is a simple question, but <strong>is "$C$1" not considered a range?</strong></p>
  
  <p>Thanks for your help.</p>
  
  <p><strong>Edit:</strong> If I use <code>Function RemoveSpecialChars(mfr As Range)</code> (without <code>ByVal</code>), I then get a <code>Type mismatch</code> error.</p>
  
  <p>This further leads me to believe that "$C$1" is not considered a range.</p>
  
  <p><strong>Edit2:</strong></p>
  
  <p>@sous2817</p>
  
  <p>This is how I set up the string <code>mfr</code> to be used with your function.</p>
  
  <pre><code>Range("C1").FormulaR1C1 = mfr
  </code></pre>
  
  <p>This is how I attempt to apply it.</p>
  
  <pre><code>Range("C1").FormulaR1C1 = RemoveSpecialChars(C1)
  </code></pre>