Ocultar colunas usando um botão

Anonim

Se você precisa ocultar certas colunas usando um botão, você pode usar este código. Irá até mesmo alterar o texto do botão de comando para Ocultar colunas e, em seguida, alterá-lo novamente para Reexibir colunas.

Sub Hide_C ()

Dim C_ell As Range

ActiveSheet.Shapes.Range (Array ("Botão 2")). Selecione

Se Selection.Characters.Text = "Reexibir Colunas" Então

Columns.Hidden = False

Selection.Characters.Text = "Ocultar colunas"

Outro

Para Cada C_ell In Range ("B1", Cells (1, Columns.Count) .End (xlToLeft))

Se C_ell = "x" Então C_ell.Columns.Hidden = True

Próximo

Selection.Characters.Text = "Reexibir colunas"

Fim se

Intervalo ("A2"). Selecione

End Sub