Add new sheets to an excisting excel document

Ignace

New Member
Hi everyone,

I 'm trying to add new sheets to an excisting excel document and i want
to add the new sheets after the excisting sheets.
I must do this in two steps : first add a sheet before the last sheet (add is always BEFORE the active sheet) and then switch the new sheet with the last sheet.
The code i use gives no errors and i have a new sheet moved
to the last position. Just what i need.
But when i close excel (With the excel menu : file - exit)
i get the well know error : this program has performed an illegal
operation and will be shut down.
When i don't move the sheets (just add new sheets)
i don't have the error.

For the code : see attachement

Thanks,
Ignace
 

Attachments

  • add excel sheet.txt
    1.4 KB · Views: 86

Sean

New Member
Heres a little module that should do the trick!
This Sub will add a new Sheet and then move it to the end.
Let me know if thats what your talking about!
Good Luck
Sean

Sub MoveSheet()
Dim SheetCount As Integer
Sheets.Add
SheetCount = Sheets.Count
ActiveSheet.Select
ActiveSheet.Move After:=Sheets(SheetCount)
End Sub
 
Top