ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy/Paste Worksheet to End of Workbook (https://www.excelbanter.com/excel-programming/395575-copy-paste-worksheet-end-workbook.html)

DBavirsha

Copy/Paste Worksheet to End of Workbook
 
I have the following code written in a macro:

Application.Goto Reference:="'Worksheet A'!RC"
Sheets("Worksheet A").Copy After:=Sheets(5)

What I really want to do is copy 'Worksheet A' after the last worksheet in
my workbook regardless of how many worksheets there are in the workbook, and
NOT always after Sheet 5.

Thanks for your help.

reklamo

Copy/Paste Worksheet to End of Workbook
 
Try following code:

Application.Goto Reference:="'Worksheet A'!RC"
Sheets("Worksheet A").Copy After:=Sheets(ActiveWorkbook.Sheets.Count)



Regards
reklamo



"DBavirsha" wrote:

I have the following code written in a macro:

Application.Goto Reference:="'Worksheet A'!RC"
Sheets("Worksheet A").Copy After:=Sheets(5)

What I really want to do is copy 'Worksheet A' after the last worksheet in
my workbook regardless of how many worksheets there are in the workbook, and
NOT always after Sheet 5.

Thanks for your help.


DBavirsha

Copy/Paste Worksheet to End of Workbook
 
Worked like a charm. Thanks for your quick help!!

Dave

"reklamo" wrote:

Try following code:

Application.Goto Reference:="'Worksheet A'!RC"
Sheets("Worksheet A").Copy After:=Sheets(ActiveWorkbook.Sheets.Count)



Regards
reklamo



"DBavirsha" wrote:

I have the following code written in a macro:

Application.Goto Reference:="'Worksheet A'!RC"
Sheets("Worksheet A").Copy After:=Sheets(5)

What I really want to do is copy 'Worksheet A' after the last worksheet in
my workbook regardless of how many worksheets there are in the workbook, and
NOT always after Sheet 5.

Thanks for your help.


Keithlo

Copy/Paste Worksheet to End of Workbook
 
Try this:

Dim MySheetIndex
MySheetIndex = 1
For Each Sheet In Worksheets
If Sheet.Index MySheetIndex Then
MySheetIndex = Sheet.Index
End If
Next Sheet

Application.Goto Reference:="'Worksheet A'!RC"
Sheets("Worksheet A").Copy After:=Sheets(MySheetIndex)

Hope this helps,

Keith


"DBavirsha" wrote:

I have the following code written in a macro:

Application.Goto Reference:="'Worksheet A'!RC"
Sheets("Worksheet A").Copy After:=Sheets(5)

What I really want to do is copy 'Worksheet A' after the last worksheet in
my workbook regardless of how many worksheets there are in the workbook, and
NOT always after Sheet 5.

Thanks for your help.



All times are GMT +1. The time now is 10:47 AM.

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