Excel表格中用宏控制隐藏及显示指定的栏位

2025-04-13 19:33:54
推荐回答(1个)
回答1:

用按钮的方法较好,代码如下,详见附件

Private Sub CommandButton1_Click()

   If CommandButton1.Caption = "隐藏列" Then

      Columns("G:AB").Hidden = True

      CommandButton1.Caption = "显示列"

   Else

      Columns("G:AB").Hidden = False

      CommandButton1.Caption = "隐藏列"

   End If

End Sub