Copy a worksheet

N

Nev

H Guys

can you help. i want to copy a sheet from a closed book into an open book
via vba macro.
Example is - run code to open the workbook, copy the only worksheet in that
book and paste it into an existing sheet in a workbook that is already open.

Can u help

Thanks

Nev
 
J

JLGWhiz

You left a lot of unanswered questions so I took some liberties. You will
have to change the name "Somefile" to the actual workbook name that you want
to copy from.

Sub cpySht()
Dim wb1 As Workbook, wb2 As Workbook
Set wb1 = ActiveWorkbook
myPath = wb1.Path
fName= myPath & "Somefile.xls" <<<Sustitute actual wb name
Worbooks.Open fName
Set wb2 = ActiveWorkbook
wb2.Sheets(1).Cells.Copy wb1.Sheets(Sheets.Count).Range("A1")
Application.CutCopyMode = False
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top