title: Range with Cells Function (Runtime Error - 1004 --> Application-defined or object Defined error)
body: <p>Could you please help on the below code.</p>
  <p>I have 2 workbooks and i want to copy the columns from one to another with the matching header.</p>
  <p>It shows an error in the following line as (Runtime Error - 1004 --&gt; Application-defined or object Defined error)</p>
  <p><code>tWB.sheets(&quot;Main&quot;).Range(Cells(TLRow, TCol)) = aWB.sheets(1).Range(Cells(2, SCol), Cells(SLRow, SCol))</code></p>
  <pre><code>Sub Pull ()
  
  
  
  Dim FileName() as Variant, nw as integer, i as integer
  
  Dim tWB as Workbook, aWB as Workbook
  
  Dim hcell as Range, Header as Range
  
  Dim SCol as Integer, TCol as Integer, SLRow as Integer, TLRow as Integer, SIndex as Integer,
  
  Dim TIndex as Integer
  
  
  
  Set tWB = ThisWorkbook
  
  FileName = Application.GetOpenFilename(FileFilter:=&quot;Excel Workbooks (*.xls; *.xlsm),*.xls;*.xlsm&quot;, MultiSelect:=True)
  
  nw = UBound(FileName)
  
  
  
  Set Header = tWB.sheets(&quot;List&quot;).Range(&quot;A1:A&quot; &amp; tWB.Sheets(&quot;List&quot;).Range(&quot;A&quot; &amp; Rows.Count).End(xlUp).Row)
  
  
  
  For i = 1 to nw
  
       Workbooks.Open FileName(i)
  
       Set aWB = ActiveWorkbook
  
           For each hcell in Header
  
               SCol = Application.Match(hcell.value, aWB.Sheets(1).Rows(1),0)
  
               TCol = Application.Match(hcell.Offset(0,1).value, tWB.Sheets(&quot;Main&quot;).Rows(1),0)
  
               SLRow = aWB.Sheets(1).Cells(aWB.Sheets(1).Rows.Count, &quot;A&quot;).End(xlUP).Row
               TLRow = tWB.Sheets(&quot;Main&quot;).Cells(tWB.Sheets(1).Rows.Count, TCol).End(xlUP).Row + 1
               SIndex = Split(aWB.sheets(1).cells(1,SCol).Address, &quot;$&quot;)(1)
  
               TIndex = Split(tWB.sheets(&quot;Main&quot;).cells(1,TCol).Address, &quot;$&quot;)(1)
  
  
               tWB.sheets(&quot;Main&quot;).Range(Cells(TLRow, TCol)) = aWB.sheets(1).Range(Cells(2, SCol), Cells(SLRow, SCol))
    
           Next hcell
  
  Next i
  
  End Sub
  </code></pre>
  <p>Another Method:</p>
  <p>Also i have tried to convert the column index number to Letter but am not sure what the error is since the code shows no error but the output is not coming</p>
  <p><code>tWB.Sheets(&quot;Main&quot;).Range(TIndex &amp; TLRow) = aWB.sheets(1).Range((SIndex &amp; 2), Range(SIndex &amp; SLRow))</code></p>