title: Trim a cell with VBA in a loop
body: <p>I'm trying to use the trim function without success. After searching for the solution on this forum and other sources online I have seen many different approaches. </p>
  
  <p>Is there no simple way of trimming a cell in VBA?</p>
  
  <p>What I want is something like this:</p>
  
  <pre><code>Sub trimloop()
  
  Dim row As Integer
  
  row = 1
  
  Do While Cells(row, 1) &lt;&gt; ""
  
     Cells(row, 2) = trim(Cells(row, 2))
  
     row = row + 1
  
  Loop
  </code></pre>
  
  <p>So that when there is a value in column A (1) the value in column B (2) should be trimmed of any extra spaces. I just cant get this to work for me.</p>
  
  <p>Appreciate any help/tips!</p>
  
  <p>Regards
  Jim</p>