2 toggle buttons..

m_ust

New Member
Joined
Sep 18, 2022
Messages
1
Office Version
  1. 2021
Platform
  1. Windows
Hi to everyone!

I created 2 custom toggle buttons with Office RibbonX Editor. So my question is hot to connect them - i mean when i toggle one button - other one should be untoggled.

Here is some code from Office RibbonX Editor:

Code:
      <group id="customGroup4" label="Фільтрація за датою">
                     <toggleButton id="toggleButton1" label="На сьогодні" onAction = "show_today" imageMso = "QueryMakeTable" size = "large"/>
                     <separator id="separator1" />
                     <toggleButton id="toggleButton2" label="Цього тижня" onAction = "show_week" imageMso = "ChartEditDataSource" size = "large"/>
                </group>

And here is my macros which are connected to buttons:

VBA Code:
Sub show_today(control As IRibbonControl, pressed As Boolean)

Dim lo As ListObject
Dim iCol As Long
Set lo = Sheets("Âõ³äí³").ListObjects("Òàáëèöà1")
iCol = lo.ListColumns("Âèêîíàòè äî").Index

If pressed = True Then
lo.AutoFilter.ShowAllData
 With lo.Range
    .AutoFilter Field:=iCol, _
                Operator:=xlFilterDynamic, _
                Criteria1:=xlFilterToday
 End With
 
Else
lo.AutoFilter.ShowAllData
End If

End Sub
Sub show_week(control As IRibbonControl, pressed As Boolean)

Dim lo As ListObject
Dim iCol As Long
Set lo = Sheets("Âõ³äí³").ListObjects("Òàáëèöà1")
iCol = lo.ListColumns("Âèêîíàòè äî").Index

If pressed = True Then
lo.AutoFilter.ShowAllData
 With lo.Range
    .AutoFilter Field:=iCol, _
                Operator:=xlFilterDynamic, _
                Criteria1:=xlFilterThisWeek
 End With
 
Else
lo.AutoFilter.ShowAllData
End If

End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,215,949
Messages
6,127,888
Members
449,411
Latest member
AppellatePerson

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