ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Moving worksheets using VBA (https://www.excelbanter.com/excel-programming/430660-moving-worksheets-using-vba.html)

RobJ

Moving worksheets using VBA
 

I am trying to add a function in a Macro that will copy the first worksheet
in a workbook to AFTER the last worksheet in the same book using Excel 2000.

The syntax I am using is
Sheets(1).Select
Sheets(1).Copy After:=Sheets(2)
which works fine if I only have 2 worksheets but not if I have 9, or if the
number of worksheets change each time the worksheet opens (which is the
purpose of the macro)

Can any one help please??

JLGWhiz

Moving worksheets using VBA
 

Sheets(1).Copy After:=Sheets(Sheets.Count)



"RobJ" wrote:

I am trying to add a function in a Macro that will copy the first worksheet
in a workbook to AFTER the last worksheet in the same book using Excel 2000.

The syntax I am using is
Sheets(1).Select
Sheets(1).Copy After:=Sheets(2)
which works fine if I only have 2 worksheets but not if I have 9, or if the
number of worksheets change each time the worksheet opens (which is the
purpose of the macro)

Can any one help please??


RobJ

Moving worksheets using VBA
 

Thanks very much for your help. It works fantastically

"JLGWhiz" wrote:

Sheets(1).Copy After:=Sheets(Sheets.Count)



"RobJ" wrote:

I am trying to add a function in a Macro that will copy the first worksheet
in a workbook to AFTER the last worksheet in the same book using Excel 2000.

The syntax I am using is
Sheets(1).Select
Sheets(1).Copy After:=Sheets(2)
which works fine if I only have 2 worksheets but not if I have 9, or if the
number of worksheets change each time the worksheet opens (which is the
purpose of the macro)

Can any one help please??



All times are GMT +1. The time now is 01:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com