title: VBA Copy 2 Columns based on value of 1 From One Workbook to Another
body: <p>Trying to copy account numbers and instances of a transaction from 2 columns (Columns "C" and "D", beginning at row 13) in a selected workbook to my workbook, but only if the value in Column D is greater than 1. Also, the last row in the column is labeled "Grand Total", so obviously I want to not included that row.</p>
  
  <p>So far, this is what I have:</p>
  
  <pre><code>Private Sub CmdGetData_Click()
  
  Dim wb As Workbook, wb2 As Workbook
  Dim NewFile As Variant
  Dim ws As Worksheet, ws2 As Worksheet
  
  
  NewFile = Application.GetOpenFilename("Excel-files (*.xlsx*, *.xlsx*")
  
  If NewFile &lt;&gt; False Then
  Set wb = ThisWorkbook
  Set wb2 = Workbooks.Open(NewFile)
  End If
  
  Set ws = Worksheets("Main")
  Set ws2 = wb2.Worksheets("IVR Late Fee Clean Up")
  
          lastrow1 = ws.Cells(Rows.Count, 2).End(xlUp).Row
  
          For i = 13 To lastrow2
              lastrow2 = wb2.ws2.Cells(Rows.Count, 3).End(xlUp).Row
              If wb2.ws2.Range("C" &amp; i).Value = "Grand Total" Then GoTo Skip
              If wb2.ws2.Range("D" &amp; i).Value = "2" Then
                  wb.ws.Range("B" &amp; lastrow1 + 1).Value = wb2.ws2.Range("C" &amp; i)
                  wb.ws.Range("C" &amp; lastrow1 + 1).Value = wb2.ws2.Range("D" &amp; i)
              End If
          Next i
  Skip:
  
  End Sub
  </code></pre>
  
  <p>The problem I am getting is "Run-time error '9': Subscript out of range".</p>
  
  <p>Please help!</p>