title: Need Macro/Function/formula to Replace the Values of one Excel Sheet if both Email(Column) value matches
body: <p>I have 2 Excel 2007 Worksheets.</p>
  
  <p>Excel Worksheet 1 : (as below ) 3 Columns are important in Sheet 1 </p>
  
  <pre><code>userid   name   email
  
  100      sam    sam@sam.com
  200      pete   pete@pete.com
  300      Bum    Bum@Bum.com 
  400      Harry  Harry@Harry.com
  </code></pre>
  
  <p>Worksheet 2 : (as below) ( user_id column is empty for all )</p>
  
  <pre><code>userid   name   email
  
           sam    sam@sam.com
           Harry  Harry@Harry.com 
           pete   pete@pete.com
           Bum    Bum@Bum.com 
  </code></pre>
  
  <p>I need a function/forumla with a macro where i can fill the values for userid in sheet 2
  where the sheet2 email = sheet1 email</p>
  
  <p>which will result as following in worksheet 2 </p>
  
  <pre><code>userid   name   email
  
  100      sam    sam@sam.com
  400      Harry  Harry@Harry.com 
  200      pete   pete@pete.com
  300      Bum    Bum@Bum.com 
  </code></pre>
  
  <p>I know SQL but the query takes a long long time on MySQL DB to get the result...
  Anyways below is the SQL query i was using in the DB. </p>
  
  <pre><code>UPDATE  `j_A` 
  SET user_id =   ( SELECT j_B.id
  FROM j_B
  WHERE j_B.email =  j_A.email)
  WHERE EXISTS
    ( SELECT j_B.id
      FROM j_B
      WHERE j_B.email =  j_A.email);
  </code></pre>
  
  <p>Need Macro/Function/formula to Replace the Values of one Excel Sheet if both Email(Column) value matches,, if anyone cud help me regarding this creating Macro/Formula/functin etc...since 
  dont have much knowldge of creating formulae in Excel Macros..</p>
  
  <p>Thanks in advance.</p>