title: Column number - copying and pasting from file to another file
body: <p>I have a little problem with my code. I want to copy my data from one file to my main file. When I check the code I meet with one problem. The code works fine until copied. In this line</p>
  <p><strong><code>Set cell1 = wsDest.Cells(1, Range(&quot;B1&quot;).End(xlToRight).Column + 1)</code></strong></p>
  <p>the cell is selected from the file from I am taking the data and not the folder I am pasting into.</p>
  <p>I want my data to paste from these other files into the main file. I want to add them as columns, not rows.</p>
  <pre><code>
  Sub MoveCopyRowsColumns()
  
  Dim mainWb As Workbook
  Dim newWb As Workbook
  Dim mainWs As Worksheet
  Dim newWs As Worksheet
  Dim strFolder As String
  
  Set mainWb = Workbooks(&quot;Main_file.xlsm&quot;)
  Set mainWs = mainWb.Worksheets(&quot;Worksheet1&quot;)
  
  mainWs.Cells(1, Range(&quot;B1&quot;).End(xlToRight).Column + 1).Select
  mainWs.Columns(ActiveCell.Column).EntireColumn.Delete
  
      strFolder = &quot;C:\Users\User1\Desktop\Folder_with_files\&quot;
      strFile = Dir(strFolder &amp; &quot;*.xls*&quot;)
      Do While strFile &lt;&gt; &quot;&quot;
          Set newWb = Workbooks.Open(strFolder &amp; strFile)
          Set newWs = newWb.Sheets(1)
          
          strFile = Dir
          
          newWs.Cells(1, Range(&quot;B1&quot;).End(xlToRight).Column + 1).Select
          newWs.Columns(ActiveCell.Column).EntireColumn.Delete
          
          newWs.Range(&quot;B1&quot;, Range(&quot;B1&quot;).End(xlDown).End(xlToRight)).Copy _
          mainWs.Range(&quot;P1&quot;)
          
      Loop
  
  End Sub
  
  </code></pre>