How do I assign different subs to user buttons?

Some videos you may like

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
35,508
Office Version
365
Platform
Windows
How about

Rich (BB code):
Sub Knockoutpie()
   Dim Shp As Shape
   Dim Cl As Range, Rng As Range
   
   Set Shp = ActiveSheet.Shapes(Application.Caller)
   Select Case Shp.Name
      Case "NorthEast"
         Set Rng = Range("E2:E20")
      Case "SouthEast"
         Set Rng = Range("F2:F20")
      Case Else
         Exit Sub
   End Select

   For Each Cl In Rng
      If Evaluate("isref('" & Cl.Value & "'!A1)") Then
         Worksheets(Cl.Value).Visible = Not .Worksheets(Cl.Value).Visible
      End If
   Next Cl
   Worksheets("Views").Activate
End Sub
Change the part in red to match the names of your buttons.
 

Forum statistics

Threads
1,089,200
Messages
5,406,792
Members
403,106
Latest member
AliO

This Week's Hot Topics

Top