title: Perform trim function on the selected cells in VBA
body: <p>I am trying to figure out if there is a way I could run a simple function (TRIM to remove duplicate space characters) in an Excel macro so it is performed directly on the cell and so I don't have to create an extra column with the function that TRIMs the previous column.</p>
  
  <p>It should work on <strong>selected column</strong> or just <strong>selected cells</strong></p>
  
  <pre><code>Sub trim()
  
   ActiveCell.FormulaR1C1 = "=trim(R1C1)"
  
  End Sub
  </code></pre>