VBA - Run Time Error 1004 'Application Defined or Object Defined'
<p>I want to copy a range of table and paste it in a new workbook. I want to copy ranges composed of other columns and rows but as variable. For example, I copy columns C and E with the rows from 1 to 17, 20, from 32 to 39 and 45. And I want to proceed that maximum 10 times (for the columns) and if I finish selecting the columns to copy, I exit. To be more clear, there is an example: I select column B, D, F and than select the rows to be copied (they are the same for all the columns) and finally copy them and paste them in a new workbook. So I stopped after three times and copy what I selected and go out.</p>

<p>My Code:</p>

<pre><code>Sub Macro33()
Dim col As String, row As String
'Dim row As Integer
Dim CopyRange As Range
Set CopyRange = [A:A]

  For i = 1 To 10
    col = InputBox("Column number " &amp; i &amp; ", if finish write 'done'")
    If col = "done" Then
      MsgBox ("copy finished")
      GoTo ExitIteration
    Else
      row = InputBox("row number to copy (max to 62), if finish write 'done'")
      Do While row &lt;&gt; "done"
        Set CopyRange = Union(CopyRange, Range(col &amp; row &amp; ":" &amp; col &amp; row))
        row = InputBox("row number to copy (max to 62), if finish write 'done'")
      Loop
    End If
  Next

 ExitIteration:
   CopyRange.copy
   Workbooks.Add
   ActiveSheet.Paste
   Windows("Pedro.xlsm").Activate
 End Sub
</code></pre>

<p>The problem is in the Line:</p>

<pre><code>  Set CopyRange = Union(CopyRange, Range(col &amp; row &amp; ":" &amp; col &amp; row))
</code></pre>

<p>I always get <strong>application-defined or object-defined error (error 1004)</strong> and can't find any solution for it!!
Any help please?</p>