Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 145
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 31
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to run relative to current selected cell MahD Excel Discussion (Misc queries) 3 December 11th 06 06:18 AM
Macro Help (Uppercase multiple ranges?) Ken Excel Discussion (Misc queries) 14 December 2nd 06 07:23 PM
Macro pulling data from 2 worksheets billrl34 Excel Discussion (Misc queries) 2 December 12th 05 08:50 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Record Macro Relative does not work? lbbss Excel Discussion (Misc queries) 3 December 13th 04 08:43 PM


All times are GMT +1. The time now is 06:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"