title: How do I get character count from cell
body: <p><strong>Goal:</strong> I'm trying to add a feature to my Excel 2016 VSTO plugin. The feature will get 1 column from the active sheet, and iterate over it changing the background color based on string length.</p>
  
  <p><strong>Problem:</strong> I'm having trouble getting string length from the cells.  I can not figure out the proper syntax I currently have <code>var count = row.Item[1].Value2.Text.Length;</code></p>
  
  <p><strong>Code:</strong> Here is what I have</p>
  
  <pre><code>    public void CharacterLengthCheck(int length = 24, int Column = 3)
      {
          Worksheet sheet = Globals.ThisAddIn.Application.ActiveSheet;
          var RowCount = sheet.UsedRange.Rows.Count;
          Range column = sheet.Range[sheet.Cells[1, Column], sheet.Cells[RowCount, Column]];
          foreach (Range row in column)
          {
              var count = row.Item[1].Value2.Text.Length;
              if (count &gt; length)
              {
                  row.Item[1].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red);
              }
              else
              {
                  row.Item[1].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Green);
              }
          }
      }
  </code></pre>