View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Application activation and pasting

Hi Samuel

If you only want to copy the cells from the first sheet in the workbook you can use this

Sub test()
Dim wb1 As Workbook
Dim wb2 As Workbook
Set wb1 = ThisWorkbook
Set wb2 = Workbooks.Add(1)
wb1.Sheets(1).Cells.Copy wb2.Sheets(1).Cells(1)
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Samuel Barnhouse" wrote in message news:Q0h4e.179$KI6.60@okepread07...
All,

I am trying to create a macro to select all data in a current workbook, copy it to the clipboard, create a new workbook and paste
the data into that workbook. This is a sample of the code I am using:

Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Workbooks.Add
Workbooks(2).Activate
Range("A1").Select
ActiveSheet.Paste

This code results in a new workbook being generated, the focus going to the new workbook, but the paste command is pasted overtop
of my original spreadsheet... Any help would be appriciated.

Thank you,
Sam Barnhouse