2 Attachment(s)
Add logic to control brightness of shape/button objects?
Hello!
See my notated image for a clear look at what I'm working with.
For the shape/buttons noted, each time one is clicked, I'd like the button's brightness to fade to 50%, to indicate that it's the associated ROW FIELD currently in use, in the associated pivot table.
I'd also like all of the buttons NOT in use to return to 100% brightness.
Attachment 31185
Most of the code in use is from Excel Campus, as noted in the code
Code:
Sub Add_Row_Field()
'Author: Jon Acampora, Excel Campus
'Swaps out Row Fields, via a button that has the macro assigned to it
'Remove all Row fields and add the Row field to the pivot table.
'The field is determined by the button text that calls the macro (i.e. name the button with the EXACT name of the Field that it's assigned to)
Dim pt As PivotTable
Dim pf As PivotField
Dim sField As String
For Each pt In ActiveSheet.PivotTables
'Set variables
sField = ActiveSheet.Shapes(Application.Caller).TextFrame.Characters.Text
'Remove existing fields
For Each pf In pt.RowFields
If pf.Name <> "Structure Level 02" Then
' This is the line that makes the Level 2 Row Field stay in place
End If
Next pf
'Add field that button was clicked for
pt.PivotFields(sField).Orientation = xlRowField
pt.PivotFields(sField).Position = 1
Next pt
End Sub
Mr. Acampora also included some logic (below) to achieve what I'm trying to do, but it was in a different procedure.
And I'm just inexperienced enough to not be able to work my way through the required if statements and where they need to go, in order to get this to work.
Each attempt resulted in the button brightness changing in some way...just not the right way.
Code:
shp.Fill.ForeColor.Brightness = 0.5
shp.Fill.ForeColor.Brightness = 0
Any help will be much appreciated :)