title: VBA macro to fill in cell based on 2 different fields that match to a list of values
body: <p>I have a Button I want to assign a macro to that, when clicked, enters in the number 1 into a specific cell on another sheet within the same workbook. This macro needs to a) match the value in cell B8 to a range of values in another sheet column (G11:G110) and also b) match the value in cell C4 to a range of values in another sheet rows (L4:FR4). </p>
  
  <p>So if the value in B8 = 01234 it will do a vlookup type function on G11:G110. Once it finds its match, it then looks at the value in C4 = "Application" and finds it match in L4:FR4. I should note that there are no duplicate values in any field and the values in L4:FR4 are static, whereas the values in cells G11:G110 change upon refresh. </p>
  
  <p>I have tried Select Case, If...And...Then... and the only thing I got to work was simply saying 
  If B8 = G11 Then blah blah L11
  If B8 = G12 Then blah blah L12</p>
  
  <pre><code>Sub RectangleRoundedCorners1_Click()
  
  Dim sourceSht As Worksheet: Set sourceSht = DataEntry
  Dim destSht As Worksheet:   Set destSht = Labels
  Dim Selection As Range:     Set Selection = DataEntry.Range("C5")' This is the # 1 I was talking about'
  Dim Acct As Range:          Set Acct = DataEntry.Range("B8")
  Dim SpecErr As Range:       Set SpecErr = DataEntry.Range("C4")
  
  If (SpecErr.Value = Labels.Range("L4")) And (Acct.Value = Labels.Range("G11")) Then
      Selection.Copy Destination:=Labels.Range("L11")
  End If
  If (SpecErr.Value = Labels.Range("M4")) And (Acct.Value = Labels.Range("G11")) Then
      Selection.Copy Destination:=Labels.Range("M11")
  End If
  End Sub
  </code></pre>
  
  <p>I ran out of space in the code doing it like this, as I need to go from L4 to FR4, and then do this 100 times by adjusting G11 to G12 &amp; L11 to L12 etc.</p>
  
  <p>The sheet holding the main data and Button I called DataEntry, and the sheet that I need to lookup on and have the 1 entered on is called Labels.</p>