Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save logic2design/06cf83c363aff33c8b3302bc7578010e to your computer and use it in GitHub Desktop.
Save logic2design/06cf83c363aff33c8b3302bc7578010e to your computer and use it in GitHub Desktop.
Refreshes Pivot tables and Queries on Excel value change
‘Option 1: 2 Button Shapes per Tab | 2 Macros
Sub Display_Tab_Sales_RevenueQ
With ActiveSheet
‘Visibility of Tab Buttons
.Shapes("Tab_Button_Sales_Revenue_Inactive").Visible = False
.Shapes("Tab_Button_Sales_Revenue_Active").Visible = True
.Shapes("Tab_Button_Sales_Units_Inactive").Visible = True
.Shapes("Tab_Button_Sales_Units_Active").Visible = False
‘Visibility of Tab Contents
.Shapes("Map_Chart_Sales_Revenue").Visible = True
.Shapes("Line_Chart_Sales_Revenue”).Visible = True
.Shapes("Map_Chart_Sales_Units").Visible = False
.Shapes("Line_Chart_Sales_Revenue").Visible = True
End With
End Sub
Sub Display_Tab_Sales_Units()
With ActiveSheet
‘Visibility of Tab Buttons
.Shapes("Tab_Button_Sales_Revenue_Inactive").Visible = True
.Shapes("Tab_Button_Sales_Revenue_Active").Visible = False
.Shapes("Tab_Button_Sales_Units_Inactive").Visible = False
.Shapes("Tab_Button_Sales_Units_Active").Visible = True
‘Visibility of Tab Contents
.Shapes("Map_Chart_Sales_Revenue").Visible = False
.Shapes("Line_Chart_Sales_Revenue").Visible = False
.Shapes("Map_Chart_Sales_Units").Visible = True
.Shapes("Line_Chart_Sales_Units").Visible = True
End With x
End Sub
‘Option 2: 1 Button Shape per Tab | 2 Macros
Sub Display_Tab_Sales_Revenue()
With ActiveSheet
‘Visibility of Tab Buttons
With .Shapes("Tab_Button_Sales_Revenue")
.TextFrame.Characters.Font.Color = RGB(O, 0, 0)
.Fill.Transparency = O#
End With
With .Shapes("Tab_Button_Sales_Units")
.TextFrame.Characters.Font.Color = RGB(255, 255, 255)
.Fill.Transparency = 1#
End With
‘Visibility of Tab Contents
.Shapes("Map_Chart_Sales_Revenue").Visible = True
.Shapes("Line_Chart_Sales_Revenue").Visible = True
.Shapes("Map_Chart_Sales_Units").Visible = False
.Shapes("Line_Chart_Sales_Units").Visible = False
End With
End Sub
Sub Display_Tab_Sales_Units()
With ActiveSheet
‘Visibility of Tab Buttons
With .Shapes("Tab_Button_Sales_Revenue")
.TextFrame.Characters.Font.Color = RGB(255, 255, 255)
.Fill-Transparency = 1#
End With
With .Shapes("Tab_Button_Sales_Units")
.TextFrame.Characters.Font.Color = RGB(O, 0, 0)
.Fill. Transparency = 0#
End With
‘Visibility of Tab Contents
.Shapes("Map_Chart_Sales_Revenue").Visible = False
.Shapes(Line_Chart_Sales.Revenue").Visible = False
.Shapes("Map_Chart_Sales_Unitk").Visible = True
.Shapes("Line_Chart_Sales_Units").Visible = True
End With
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment