title: VBA Excel sort range by specific column
body: <p>I have a table that can contain any number of rows:</p>
  
  <p><img src="https://i.stack.imgur.com/LwwBf.png" alt="enter image description here"></p>
  
  <p>As I said it can contain 1 or ∞ rows.</p>
  
  <p>I want to sort range <code>A3:D∞</code> by the Date cell that is in column B.<br>
  How can I do it?</p>
  
  <p>The problem is that I don't know how to select from <code>A3</code> to the last row.</p>
  
  <p>I think that looping to the last row is not a correct method.</p>
  
  <p>I have got this so far it sorts looks like correct, but the range is hard-coded.<br>  How do I get rid of the hard-coding of the range?</p>
  
  <pre><code>Range("A3:D8").Sort key1:=Range("B3:B8"), _
  order1:=xlAscending, Header:=xlNo
  </code></pre>