title: Match 2 arrays with rows' values
body: <p>I want to write a code that uses two 1D arrays and based on the match with the value on the row, it should return the value in the 3rd array. </p>
  
  <p>This is what I want to do:</p>
  
  <p>In Sheet1, I have 3 columns with data on ID, Name, and Amount with a number of rows of uncertain size:
  <a href="https://i.stack.imgur.com/99Hlu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/99Hlu.png" alt="enter image description here"></a></p>
  
  <p>In Sheet2, I have already the columns with data on ID and Name but I don't have the data on Amount:</p>
  
  <p><a href="https://i.stack.imgur.com/BQPjd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BQPjd.png" alt="enter image description here"></a></p>
  
  <p>Therefore, I want to run the code that will match the arrays with ID and Name data in Sheet1 with ID and Name data in Sheet2 and then, return the respective Amount data to Sheet2 as it is in Sheet1. </p>
  
  <p>This is the desired outcome in Sheet2 after running the code, i.e. the data in column Amount are returned based on the match with arrays on ID and Name in Sheet1:
  <a href="https://i.stack.imgur.com/qtCLi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qtCLi.png" alt="enter image description here"></a></p>
  
  <p>This is my code that does not run as it should:</p>
  
  <pre><code>Sub ArrayMatch()
  
  Dim r As Long
  Dim d As Long
  Dim w_output As Worksheet
  Dim w1 As Worksheet
  Dim intLastRow As Integer
  Dim IntLastCol As Integer
  Dim arrName() As Variant
  Dim arrID() As Variant
  Dim arrrAmoun() As Variant
  
  d = 8
  
  With ThisWorkbook
      Set w1 = .Sheets("Sheet1")
      Set w_output = .Sheets("Sheet2")
  End With
  
  '***********************************
  'Assign arrays
  
  With w1
  
      intLastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
      IntLastCol = .Cells(4, Columns.Count).End(xlToLeft).Column
      arrID = .Range(.Cells(4, 1), .Cells(intLastRow, 1))
      arrName = .Range(.Cells(4, 3), .Cells(intLastRow, 2))
      arrAmoun = .Range(.Cells(4, 4), .Cells(intLastRow, 3))
  
      For r = 1 To UBound(arrID, 1)
          If Len(arrID(r, 1)) &gt; 0 Then
              d = d + 1
                  If w_output.Cells(d, 1) = arrID(r, 1) Then
                      If w_output.Cells(d, 2) = arrName(r, 1) Then
                         w_output.Cells(d, 4) = arrAmoun(r, 1)
                      End If
                  End If
          End If
      Next r
  
  End With
  
  End Sub
  </code></pre>
  
  <p>My code does not return anything, I can assume that it is because I am comparing the arrays from sheet1 with rows in sheet 2 which is not comparative in the size, but I don't know how to do in another way.
  I will appreciate any help.</p>