Macro to Perform Same Function Across Selected Sheets

  • Thread starter Thread starter Skihde
  • Start date Start date
S

Skihde

Hi all,

I'm new to VBA and could use some help. I'm trying to have a macro
perform the same function (paste a rectangle) across several selected
sheets (say, 1-4,7,9,10 of 10). I can get the macro to paste the
rectangle across ALL the sheets, but I only want it on those selected.
Any ideas?

Thanks in advance,
Stephan
 
As always, post your coding efforts for comments and suggestions.
 
Here's the code I currently have:

Sub CoverStopwatch()
'
' CoverStopwatch Macro
'
Dim sh As Worksheet
For Each sh In ActiveWorkbook.Worksheets
sh.Select
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 3.75, 39.75, 79.5,
37.5). _
Select
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 19
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.Solid
Selection.ShapeRange.Line.Visible = msoFalse
Selection.ShapeRange.Shadow.Visible = msoFalse
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 4.5, 540#, 82.5,
21.75). _
Select
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 19
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.Solid
Selection.ShapeRange.Line.Visible = msoFalse
Selection.ShapeRange.Shadow.Visible = msoFalse
Range("Q1:V1").Select
Next sh
End Sub


Thanks.
 
Sub ss()
For Each ws In ActiveWindow.SelectedSheets
MsgBox ws.Name
Next ws
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top