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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vba exel Question??

Status
Not open for further replies.

lordeos

IS-IT--Management
Aug 7, 2003
91
BE
Hello,

What is the code to copy all the cells of a certain sheet to another sheet in exell. I also add a new sheet who i named (spread).

This is what i tried.

Sheets("sheet1").cells.select
Sheets("sheet1").cells.copy
set spread = sheets.add
spread.activate
spread.cells.copy

But this doesnt seem te to work.
Can anyone help me?

thx
 
Try adding the new sheet before you do the copy, when you add a new sheet in Excel "Forgets" what you copied last.
 
'aanmaken van een nieuw blad
Set spread = Sheets.Add
Windows("Overzicht Nashuatec printerpark en tellerstanden.xls").Activate
Sheets("Blad1").Cells.Select
Sheets("blad1").Cells.Copy
spread.Activate
spread.Cells.Paste
End Sub

is this better??
 
Nopes,

He starts a new session of exel but not a new sheet in the active workbook.

 
Am I right in assuming that Overzicht Nashuatec printerpark en tellerstanden.xls is the name of your active workbook? If so try:
Code:
Windows("Overzicht Nashuatec printerpark en tellerstanden.xls").Activate
Set spread = Sheets.Add
Sheets("blad1").Cells.Copy
spread.Activate
spread.Cells.Paste
Otherwise use:
Code:
activeworkbook.sheets.add
 
Yes,

the "Overzicht Nashuatec printerpark en tellerstanden.xls" is the active workbook ... there i want to insert a page where the data of another exel sheet must be copied into.

thx for the help
 
Hello,

It worked ... a made a few changes
This is the good code :

Windows("Overzicht Nashuatec printerpark en tellerstanden.xls").Activate
Set spread = Sheets.Add
Sheets("blad1").Cells.Copy
spread.Activate
spread.Cells.Select
spread.Paste
End Sub

Thx for the help.

greetz,
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top