title: Deleting duplicate Names from NamesManager using C# Interop.Excel
body: <p>I am facing some problem with deleting Names from NAmesManager in C# code.
  As per my requirement, I need to delete all the Invalid names from the Names Manager. I am currently checking for the value of the Name and deleting it if the value is "#REF!". This is the code I am using </p>
  
  <pre><code>foreach (Name RangeName in namesManager2)
                  {
  
                      if(RangeName.Value.Contains("#REF!")) 
                      {
                          RangeName.Delete();
                      }
                   }
  </code></pre>
  
  <p>The code works fine, However There are some strange situations where there exists 2 names with same Name but the scope is different. 
  Consider cell 1 is named "TESTNAME" with scope of "Workbook" and cell 2 is also named "TESTNAME" with scope "Sheet1". The name referring to Cell2 has a valid value.</p>
  
  <p>So when I am looping if the name with "#REF!" value is encountered the above code is removing both the names. I want to retain the name with valid value but delete only the invalid Name.</p>
  
  <p>Can someone suggest how to achieve this ?</p>