I need to be able to add pages to a workbook using Vb code. Each new page needs to go to the end of the workbook and be active.
I have used the following:
Sheets("TMU108 M").Visible = True
Sheets("TMU108 M").Select
Sheets("TMU108 M").Copy Before:=Sheets(14)
Sheets("TMU108 M (2)").Select
Sheets("TMU108 M (2)").Name = "TMU108 (2)"
Sheets("TMU108 M").Select
ActiveWindow.SelectedSheets.Visible = False
Sheets("TMU108 (2)").Select
This is fine for the first page but the next page is added in front of the first page. But to get the next page added to go to the end I have to change line 3 to Copy before:=Sheets(15). Since I need to add up to 30 pages there must be an easier way than re[peating this peiece of code 30 times.
Can anyone help please.
John
I have used the following:
Sheets("TMU108 M").Visible = True
Sheets("TMU108 M").Select
Sheets("TMU108 M").Copy Before:=Sheets(14)
Sheets("TMU108 M (2)").Select
Sheets("TMU108 M (2)").Name = "TMU108 (2)"
Sheets("TMU108 M").Select
ActiveWindow.SelectedSheets.Visible = False
Sheets("TMU108 (2)").Select
This is fine for the first page but the next page is added in front of the first page. But to get the next page added to go to the end I have to change line 3 to Copy before:=Sheets(15). Since I need to add up to 30 pages there must be an easier way than re[peating this peiece of code 30 times.
Can anyone help please.
John