VB to copy a sheet to active workbook

D

Darin Kramer

Howdie

I need some vb that will help solve the following...

Scenario - I got two files open

File 1 - entitled Master with sheet called final in it (always be this
set up of file and sheet name)
File 2 - VARIABLE name, ie it will change, but it can be the active book
when I run the macro.

What I need is to copy the sheet master from file 1 into file 2.

Thanks!!!!

Regards

Darin




*** Sent via Developersdex http://www.developersdex.com ***
 
R

Ron de Bruin

Hi Darin

Test this one
With file 2 active

Dim Wb1 As Workbook
Dim Wb2 As Workbook
Set Wb1 = ActiveWorkbook
Set Wb2 = Workbooks("Master.xls")
Wb2.Sheets("final ").copy _
after:=Wb1.Sheets(Wb1.Sheets.Count)
 
R

Ron de Bruin

I see I have a space after the sheet name "final "
Remove it before you test it
 
J

Jim Thomlinson

This code assumes that the code is running in th atcive workbook...

Workbooks("Master.xls").sheets("Final").Copy _
After:= ThisWorkbook.Sheets(1)

This code assumes that the code is running in Master.xls...
Thisworkbook.Sheets("Final").copy _
After:= Activeworkbook.Sheets(1)
 

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