How can I create a macro that would do the following:
- Copy the range A2:AT10000 from one workbook to the first sheet of a new workbook.
- Go back to the initial workbook and select range A6:HF10000 in the sheet with codename: Sheet11
- Paste the selection to a newly added worksheet (sheet 2) of the workbook created in step 1
I get a run time error 424 and when debugging, the highlighted line is
Sheet11.Range("A6:HF10000").Select
Sub Copy2RangesNewWorkbook()
'
' Copy2RangesNewWorkbook Macro
'
Dim pvt_wbk_New As Excel.Workbook
Dim pvt_xls_Current As Excel.Worksheet
With pvt_xls_Current
ActiveSheet.Range("A2:AT10000").Select
Selection.Copy
End With
Set pvt_wbk_New = Application.Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
With pvt_xls_Current
Sheet11.Range("A6:HF10000").Select
Selection.Copy
End With
With pvt_wbk_New
Sheets.Add After:=Sheets(Sheets.Count)
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End With
End Sub