title: Excel VBA macro for dynamic named range
body: <p>I am looking for a simple macro for creating a dynamic named range for a table with this design:</p>
  
  <pre class="lang-none prettyprint-override"><code>       A      B
  4    Title1 Title2
  5    val_1  val_a
  6    val_2  val_b
  7    val_3  val_3
  </code></pre>
  
  <p>The requirements are:</p>
  
  <ol>
  <li><p>The names of the dynamic named ranges should be equal to the headers (in this case, "Title1", "Title2").</p></li>
  <li><p>One should be able to specify on which row the header lies (e.g. row 4).</p></li>
  </ol>
  
  <p>(I have found two such macros (<a href="http://www.contextures.com/xlNames03.html" rel="nofollow">1</a>, <a href="http://www.datawright.com.au/excel_resources/excel_range_names_vba.htm" rel="nofollow">2</a>), but they all have bugs on the second requirement.)</p>