ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   in VBA Sheets("mysheet").Copy Befo=Sheets(1) how do i get a reference to the newly created copy of this sheet? (https://www.excelbanter.com/excel-worksheet-functions/34150-vba-sheets-%22mysheet%22-copy-before-%3Dsheets-1-how-do-i-get-reference-newly-created-copy-sheet.html)

Daniel

in VBA Sheets("mysheet").Copy Befo=Sheets(1) how do i get a reference to the newly created copy of this sheet?
 
in VBA Sheets("mysheet").Copy Befo=Sheets(1) how do i get a reference to
the newly created copy of this sheet?



Dave Peterson

dim newWks as worksheet

with activeworkbook
.sheets("mysheet).copy _
befo=.sheets(1)
end with
set newwks = activesheet
newwks.name = "this is a new sheet!"

(the activesheet is the one that just got created.)

Daniel wrote:

in VBA Sheets("mysheet").Copy Befo=Sheets(1) how do i get a reference to
the newly created copy of this sheet?


--

Dave Peterson


All times are GMT +1. The time now is 08:20 AM.

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