Varios Botones de alternancia (control de ActiveX)
He creado varios botones de alternancia, dentro de una sola hoja de Excel.
Private Sub ToggleButton1_Click() Dim xAddress As String xAddress = "H:N" If ToggleButton1.Value Then Application.ActiveSheet.Columns(xAddress).Hidden = True Else Application.ActiveSheet.Columns(xAddress).Hidden = False End If End Sub Private Sub ToggleButton2_Click() Dim xAddress As String xAddress = "Q:X" If ToggleButton1.Value Then Application.ActiveSheet.Columns(xAddress).Hidden = True Else Application.ActiveSheet.Columns(xAddress).Hidden = False End If End Sub Private Sub ToggleButton3_Click() Dim xAddress As String xAddress = "AC:AJ" If ToggleButton1.Value Then Application.ActiveSheet.Columns(xAddress).Hidden = True Else Application.ActiveSheet.Columns(xAddress).Hidden = False End If End Sub Private Sub ToggleButton4_Click() Dim xAddress As String xAddress = "AO:AV" If ToggleButton1.Value Then Application.ActiveSheet.Columns(xAddress).Hidden = True Else Application.ActiveSheet.Columns(xAddress).Hidden = False End If End Sub Private Sub ToggleButton5_Click() Dim xAddress As String xAddress = "BA:BH" If ToggleButton1.Value Then Application.ActiveSheet.Columns(xAddress).Hidden = True Else Application.ActiveSheet.Columns(xAddress).Hidden = False End If End Sub
Todos los demas botones de 2 al 5 dependen del botón numero 1 (ToggleButton1) para poder ocultar y desocultar columnas
- Si el botón 1 esta ocultado la columna, todos los botones tienes la opción de ocultar mas no de desocultar independientemente
- si el botón 1 esta desocultado la columna, todos los botones tienes la opción de desocultar mas no de ocultar independientemente.