title: Compare when a Variable becomes bigger than a Value in List/IEnumerable
body: <p><strong>Background/Context</strong></p>
  
  <p>I am currently building a function that will take a value and compare it against a list to find at which point the string values become bigger. The value I take is a date and the String contains a range of dates that are headings to a chart and essentially I am trying to find the column in excel where this date would fit in. The heading dates are all weekly dates. I've tried to get my logic around it but nothing seems to be working so thought I'd ask on here. </p>
  
  <p><strong>Logic Behind Code</strong></p>
  
  <ol>
  <li>The program creates a IEnumerable to find cell of records for which date we are looking up</li>
  <li>The program creates a IEnumerable with all the dates in the headings.</li>
  <li>The program takes that date and compares it to the IEnumerable in 2. to return a column where the new date will go.</li>
  </ol>
  
  <p><strong>Code up to point 2</strong></p>
  
  <pre><code>List&lt;string&gt; Sheet1Rows = new List&lt;string&gt;();
  List&lt;string&gt; Sheet2Rows = new List&lt;string&gt;();
  List&lt;DateTime&gt; ColumnDates = new List&lt;DateTime&gt;();
  //List&lt;int&gt; NewRowsNumber = new List&lt;int&gt;();
  
  for (int row = 9; row &lt;= LastRowSheet1; row++)
  {
      Sheet1Rows.Add(ExcelWksht1.Cells[row, 1].Value);
  }
  
  for (int row = 9; row &lt;= LastRowSheet2; row++)
  {
      Sheet2Rows.Add(ExcelWksht2.Cells[row, 1].Value);
  }
  
  for (int column = 16; column &lt;= LastColumnSheet2; column++)
  {
      ColumnDates.Add(ExcelWksht2.Cells[5, column].Value);
  }
  
  IEnumerable&lt;string&gt; Names1 = Sheet1Rows;
  IEnumerable&lt;string&gt; Names2 = Sheet2Rows;
  IEnumerable&lt;DateTime&gt; Dates1 = ColumnDates;
  
  IEnumerable&lt;string&gt; NamesInBoth = Names1.Intersect(Names2);
  IEnumerable&lt;string&gt; NamesOnlyInTwo = Names2.Except(Names1);
  Debug.Print("NamesInBoth\n==========");
  
  foreach (var n in NamesInBoth)
  {
      Debug.Print(n.ToString());
  
      //Get Row Values
      int rowinsheet1 = (Sheet1Rows.FindIndex(x =&gt; String.Compare(x, n) == 0)) + 9;
      int rowinsheet2 = (Sheet2Rows.FindIndex(x =&gt; String.Compare(x, n) == 0)) + 9;
  
      //Get Date Values
      var Sheet1Date = ExcelWksht1.Cells[rowinsheet1, 9].Value.ToString();
      var Sheet2Date = ExcelWksht2.Cells[rowinsheet2, 9].Value.ToString();
  
      if (Sheet1Date != "No Planned Date" &amp;&amp; Sheet2Date != "No Planned Date")
      {
          if (Sheet1Date != null &amp;&amp; Sheet2Date != null)
          {
              if (Sheet1Date.ToString() != Sheet2Date.ToString())
              {
                  //THIS IS WHERE IM STRUGGLING
              }
          }
          else 
          {
              ((Excel.Range)ExcelWksht2.Cells[rowinsheet2, 1]).EntireRow.Interior.Color = Microsoft.Office.Interop.Excel.XlRgbColor.rgbOrange;
          }
      }  
  } 
  </code></pre>
  
  <p><strong>The Problem</strong></p>
  
  <p>As shown in the code I need to figure out a way to construct a loop (?) to check the row date value against all the heading values in the IEnumerable to give me the date value that begins the 7 day range.</p>