title: How to execute a function for each cell in a column and loop through all workbooks?
body: <p>Here's what I have so far:</p>
  
  <pre><code>Sub TrimColumnD()
     Dim ws As Worksheet
  
     For Each ws In ThisWorkbook.Worksheets
     Dim c As Range
          For Each c In ActiveSheet.UsedRange.Columns("D").Cells
              c.Value = WorksheetFunction.Trim(c.Value)
          Next c
     Next ws
  
  End Sub
  </code></pre>
  
  <p>The trim function only works on the cells in the first worksheet.</p>