title: How can I get the length of the longest string in a column (Excel)?
body: <p>I have an Excel spreadsheet that I am writing out to a file.  I am currently using the following method to reproduce the contents of each cell:</p>
  
  <pre><code>cell_contents = Right(Space(10) &amp; Trim(Cells(iRow, iColumn)), 10)
  </code></pre>
  
  <p>However, if the contents of the cell are longer than 10 characters long (or however long I choose to specify), then I loose parts of the data.  Is there a way to quickly and easily get the length of the longest string in a range of cells?</p>
  
  <p>I have seen people suggest using the following loop, but I was hoping that I might be able to do it without having to loop over all the cells:</p>
  
  <pre><code>For Each c In SourceRange.Cells
     if len(c) &gt; b then b = len(c)
  Next c
  </code></pre>