title: How do I remove emojis from an excel sheet using VBA?
body: <p>I have a spreadsheet that contains emojis, e.g., , and I am looking for a solution to use Excel VBA to replace the emojis with null.  </p>
  
  <p>Emojis can be removed using the Excel replace action, so I recorded a macro to automate the replace.  I opened the recorded macro and it was displayed as follows:</p>
  
  <pre><code>Sub Remove_Emojis()
  
      Cells.Replace What:="??", Replacement:="", LookAt:=xlPart, SearchOrder _
          :=xlByRows, MatchCase:=True, SearchFormat:=False, ReplaceFormat:=False
  End Sub
  </code></pre>
  
  <p>The problem is that VBA doesn't recognize emojis () and replaces them with "??", i.e., Unicode characters above a certain value are not recognized by VBA.</p>
  
  <p>I tried replacing "??" with <code>ChrW()</code>:</p>
  
  <pre><code>Sub Remove_Emojis()
  
      Cells.Replace What:=ChrW(128515), Replacement:="", LookAt:=xlPart, SearchOrder _
          :=xlByRows, MatchCase:=True, SearchFormat:=False, ReplaceFormat:=False
  End Sub
  </code></pre>
  
  <p>but this results in an error:</p>
  
  <blockquote>
    <p>Invalid procedure call of argument</p>
  </blockquote>
  
  <p>because the ChrW() function does not allow a value above 65535.  Note: The ChrW() function works if the value of the argument is within the range -32,767 to 65,535.</p>
  
  <p>I expect that there should be support for doing this in VBA given that it can be done in Excel.</p>