title: Loop Through every cell in a range to make sure they are the same length
body: <p>I am trying to run a test to make sure that every cell in a range of cells has the same length string inside it. Basically, I want to check if every cell in a defined range has a string length of 1. If every cell is 1, then I will do something to the code, else I will do something else. I'm using an evaluate(sumproduct(length()) construct but I am getting a type mismatch. Any help would be appreciated.</p>
  
  <pre><code>Sub Name_Length()
  
  Dim aCell As Range
  Dim ws As Worksheet
  Dim LastRow As Long
  Dim NameStr As String
  Dim Namer As Range
  Dim NameResult As Integer
  Dim i As Integer
  Dim cell As Range
  
  Set ws = Sheets("Data Input")
  
  LastRow = ws.Cells(Rows.Count, "E").End(xlUp).Row
  
  For Each cell In ws.Range("E4:E" &amp; LastRow)
  NameResult = Evaluate("=SUMPRODUCT(LEN(cell))")
  Next cell
  
  If NameResult &gt;= 1 Then
   'Do something'
  Else
   MsgBox NameResult
  End If
  
  End Sub
  </code></pre>