VBA使用相同的宏按钮展开/折叠行 [英] VBA expand/collapse rows with same macro button

查看:856
本文介绍了VBA使用相同的宏按钮展开/折叠行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于如何运行简单的宏按钮,我们有一个琐碎的问题.此按钮的用途有两个:扩展行和折叠行.

We have a trivial problem regarding how to run a simple macro button. The purpose of this button is two-fold: expanding a row and collapsing a row.

1 (按下按钮)会启动此VBA命令:

1 on pressing the button this VBA command is initiated:

Sub Macro7()

Rows(7).ShowDetail = True

End Sub

此命令扩展第7行.

2 (在展开该行的同时),将启动此VBA:

2 on pressing the button again (whilst the row is expanded), this VBA is initiated:

Sub Macro7()

Rows(7).ShowDetail = False

End Sub

这会使行折叠.

是否可以将按钮链接到两个宏?

Is there a way to link a button to two macros?

提前谢谢!

M

推荐答案

Sub Macro7()  
    With Rows(7)
        .ShowDetail = Not .ShowDetail
    End With
End Sub 

这篇关于VBA使用相同的宏按钮展开/折叠行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆