Change Macro from Running when Worksheet is Activated to Be Ran on Multiple Sheets By Button in 1 Sheet

doctorgresham

New Member
Joined
Aug 2, 2021
Messages
6
Office Version
  1. 365
Platform
  1. MacOS
Hi,
I currently have the following macro on several sheets in a workbook that runs each time the sheets are activated. I'm looking to change it from being ran each time I click on the individual sheets to being ran only when a button is clicked on Sheet 1. So in other words, I want to make a button on sheet 1 that will run the following macro on sheets 2, 3, 4 etc. when i press it. I'm a novice when it comes to VB, so any help/ideas would be greatly appreciated!

Private Sub Worksheet_Activate()
Dim cell As Range
For Each cell In Range("A1:A424")
If cell.Value = "0" Then
cell.EntireRow.Hidden = True
ElseIf cell.Value = "1" Then
cell.EntireRow.Hidden = False
End If
Next
End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
65,938
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Forum statistics

Threads
1,148,176
Messages
5,745,191
Members
423,931
Latest member
thangvan114

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
Top