ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Select the ActiveSheet & the sheet next to it (https://www.excelbanter.com/excel-discussion-misc-queries/169230-select-activesheet-sheet-next.html)

Dolphinv4

Select the ActiveSheet & the sheet next to it
 
Hi,

how do I have a macro to select the activesheet and the sheet next to it and
then to copy them and insert as new sheets (both of them)? Note that for the
macro, i do not want it to have specific Named sheets.

Thanks.



John Bundy

Select the ActiveSheet & the sheet next to it
 
You left out a few minor details but this should get you to the right place.
Selects the active sheet and the one next to it (to the right) and copies to
a new workbook.
Sub selectSheets()

isheet1 = ActiveSheet.Index
isheet2 = ActiveSheet.Index + 1

Sheets(Array(isheet1, isheet2)).Select

Sheets(Array(isheet1, isheet2)).Copy

End Sub

--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Dolphinv4" wrote:

Hi,

how do I have a macro to select the activesheet and the sheet next to it and
then to copy them and insert as new sheets (both of them)? Note that for the
macro, i do not want it to have specific Named sheets.

Thanks.




All times are GMT +1. The time now is 11:12 PM.

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