Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro to create and use a new excel workbook 1

Status
Not open for further replies.

collierd

MIS
Dec 19, 2001
509
DE
Hello

I am using MS Excel 2003

I have an Excel spreadsheet with 21 worksheet (numbered 1 to 21)

I am attempting to create a macro that creates a new file and copies (using paste special - values) the contents from one of these worksheets to the file
Data Manipulation (simple row and column deletion) then takes place on this new file
I can't remove data from the original as it contains calculated fields reliant upon rows/columns that will be removed

The problem lies with the creation and use of the new file
If I record it creates:

Workbooks.Add Create new file
Windows("Book1").Activate To make active

It's only Book1 in the first instance thereafter Book2, etc
This causes an error

Any thoughts how I get round this

Thanks

Damian.
 
The easiest way would be to pre-define the new Workbook.

Dim wb As Workbook
Set wb = Workbooks.Add
wb.Activate
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top