Running one macro in several sheets by a code

Reza1001

New Member
Joined
Sep 9, 2024
Messages
6
Office Version
  1. 2021
  2. 2019
Platform
  1. Windows
Hi dears

i have a file including 30 sheets . in some sheets i have one rectangle ( named "100" ) which must be hidden/unhidden and a rounded rectangle ( named "200" ) which must be colorized . i have written two macros for this matter . one of them is this :

Sub ProtBUDCOK()
'
' ProtBUDCOK Macro
'
'
ActiveSheet.Shapes.Range(Array("Rectangle: Rounded Corners 200")).Select
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(187, 170, 43)
.Transparency = 0
.Solid

End With

Range("s1").Select
ActiveSheet.Shapes.Range(Array("Rectangle 100")).Select
ActiveSheet.Shapes.Range(Array("Rectangle 100")).Visible = msoFalse
End Sub


i want to run this macro and other one by bottoms in sheet1 for sheet2,sheet5,sheet6 and sheet9 ( with codenames ) . below code doesn't work maybe because of ActiveSheet part of above macro or wrong addressing in sheet names . please help me.

Sub RunOnAllSheets()

Application.ScreenUpdating = False

For Each Worksheet In ThisWorkbook.Worksheets
Debug.Print wrkSht.Name
Sheets(Array("Sheet2", "Sheet5", "Sheet6", "Sheet9")).Select

Call ProtBUDBOK
Next
Application.ScreenUpdating = True

End Sub
 
really appreciated . this code works perfectly . 👏
 
Upvote 0
thanks a lot . works fine 🙏
 
Upvote 0

Forum statistics

Threads
1,226,795
Messages
6,193,023
Members
453,771
Latest member
adityakiran55

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top