![]() |
Macro to work only on selected worksheets
Hi All,
I've got a macro that will paste a rectangle on a sheet. That's easy. The hard part is that I want it to do that only across selected sheets in a workbook, say sheets 1, 2, 5, 8, and 10 of 10sheets. I can get it on one sheet at a time, as well as ALL the sheets in a workbook, just not those specific ones. Any ideas? Thanks in advance, Stephan |
Macro to work only on selected worksheets
Isn't this resolved a few days ago?
-- Regards wrote in message ups.com... Hi All, I've got a macro that will paste a rectangle on a sheet. That's easy. The hard part is that I want it to do that only across selected sheets in a workbook, say sheets 1, 2, 5, 8, and 10 of 10sheets. I can get it on one sheet at a time, as well as ALL the sheets in a workbook, just not those specific ones. Any ideas? Thanks in advance, Stephan |
Macro to work only on selected worksheets
1- in vba (Alt + F11) ,insert a module.
2- Write this: Sub MyPaste() Selection.Copy Sheets(Array("Sheet2", "Sheet3")).Select 'or any sheet you want Sheets("Sheet2").Activate ' one of your sheet Range("E20").Select ' your 1st cell in paste range ActiveSheet.Paste End Sub " wrote: Hi All, I've got a macro that will paste a rectangle on a sheet. That's easy. The hard part is that I want it to do that only across selected sheets in a workbook, say sheets 1, 2, 5, 8, and 10 of 10sheets. I can get it on one sheet at a time, as well as ALL the sheets in a workbook, just not those specific ones. Any ideas? Thanks in advance, Stephan |
Macro to work only on selected worksheets
Sub test()
Dim ws As Worksheet Set MySheets = ThisWorkbook.Worksheets(Array("Sheet1", "Sheet2", "Sheet3")) 'or if you select the sheets with CTRL + Click 'Set MySheets = ActiveWindow.SelectedSheets For Each ws In MySheets 'do your stuff Next ws End Sub Gord Dibben MS Excel MVP On 21 Jan 2007 20:32:46 -0800, wrote: Hi All, I've got a macro that will paste a rectangle on a sheet. That's easy. The hard part is that I want it to do that only across selected sheets in a workbook, say sheets 1, 2, 5, 8, and 10 of 10sheets. I can get it on one sheet at a time, as well as ALL the sheets in a workbook, just not those specific ones. Any ideas? Thanks in advance, Stephan |
All times are GMT +1. The time now is 10:53 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com