title: VBA Excel: Sorting by Searching another sheet
body: <p>I'm trying to figure out how to sort information in one sheet in an Excel document by information in another sheet using a unique identifier found on both sheets.</p>
  
  <p>I have two separate sheets in Excel, <code>sheet1</code> contains user information including name, gender and a unique ID that looks more or less like this:</p>
  
  <pre><code>      A      | B |  C
  John Doe     | M | 112 
  Jane Doe     | F | 147 
  Kerry West   | F | 293
  Robert Smith | M | 861
  </code></pre>
  
  <p><code>Sheet 2</code> contains a unique identifier and a score like this:</p>
  
  <pre><code> A  | B
  112 | 15
  147 | 12
  293 | 18
  861 | 11
  </code></pre>
  
  <p>What I want to do is separate the two groups in sheet two based on gender. So basically I would somehow take the unique ID on sheet two, find it in sheet 1 and then check the gender associated with that unique ID so that sheet two would end up looking like this:</p>
  
  <pre><code> A  | B  |  C  | D
  112 | 15 | 147 | 12
  861 | 11 | 293 | 18
  </code></pre>
  
  <p>So that the rows identified as male are left in their columns while rows identified as female are moved to columns C and D. I just can't figure out how I'm meant to do this and it's driving me nuts. any help or advice would be appreciated.</p>