VBA code to always select next available new workbook

  • Thread starter Thread starter wayliff
  • Start date Start date
W

wayliff

Hi

I have a macro that adds a new workbook and copies two sheets to it
However the macro crashes if the new workboox is not book1 and it i
kind of a bummer.
I have not been able to figure how to code something to just look a
the newest workbook and copying the stuff...without vba looking a
book1 as the new workbook...just whatever is available.

Here's what I currently have...help appreciated.

Workbooks.Add
Windows("TC Report.xls").Activate
Sheets(Array("ST Report", "EF Report")).Select
Sheets("EF Report").Activate
Sheets(Array("ST Report", "EF Report")).Cop
Before:=Workbooks("Book1").Sheets _
(1)
Windows("TC Report.xls").Activate
Sheets("ST Report").Selec
 
wayliff said:
Workbooks.Add
Windows("TC Report.xls").Activate
Sheets(Array("ST Report", "EF Report")).Select
Sheets("EF Report").Activate
Sheets(Array("ST Report", "EF Report")).Copy
Before:=Workbooks("Book1").Sheets _
(1)
Windows("TC Report.xls").Activate
Sheets("ST Report").Select

Dim wb As Workbook

Set wb = Workbooks.Add

Workbooks("TC Report.xls").Sheets(Array("ST Report", "EF Report")).Copy _
Before:=wb.Sheets(1)
 
Thank you so much for your help...

This is where I can see that I have way to go in code efficiency an
knowledge..
 

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

Back
Top