title: Excel, Trying Index, Match, to lookup values with VBA
body: <p>I am trying to look-up values at cell locations using VBA, I have searched google and all over stackoverflow before asking this because I can't seem to get it to work.</p>
  
  <p>The following is the code I am trying to use, note that budgetcode references a cell containing one of the codes in the first column and mo references a cell that contains a number (1-12) or contains a short code (ytd, 1qtr, 2qtr, 3qtr). Example is that I want to pull CAD-NS for February (2), and I should get 5666.40.</p>
  
  <pre><code>Function eBudgetl(budgetcode As String, mo As String)
  eBudgetl = Application.WorksheetFunction.Index(Range("Budget!G1:X5000"), _
     Application.WorksheetFunction.Match(budgetcode, Range("Budget!B1:B5000"), 0), _
     Application.WorksheetFunction.Match(mo, Range("Budget!G1:X1"), 0))
  End Function
  </code></pre>
  
  <p>Here is part of the data I wish to lookup:</p>
  
  <pre><code>                                       1    2          3       4
  CAD-NS      I   Net Sales           5264.0  5666.4  5614.9  5966.6
  COSMAT      E   Material            6207.5  3660.0  3661.9  3560.9
  COSDL       E   Direct Labor         610.4  105.3   167.1   123.6
  CAD-MOIL    E   Indirect Labor       671.2  163.4   181.6   161.7
  CAD-MOSAL   E   Salary Overhead      601.0  106.0   101.0   101.0
  </code></pre>
  
  <p>Here is the code in the cell that works, but I need to do in VBA. (The reason I need to do in vba is sometimes the budgetcode will contain 2+ references separated by a comma and I am going to use vba to separate them and look each up independently.)</p>
  
  <pre><code>=INDEX(Budget!$G$1:$X$5000,MATCH($F12,Budget!$B$1:$B$5000,0),MATCH(AN$1,Budget!$G$1:$X$1,0))
  </code></pre>
  
  <p>I appreciate any help very much, I have been at this for 3 days now.</p>
  
  <p>Thanks,</p>
  
  <p>Enoch</p>