如何用VB让excel我做的五个表格依次隐藏和显示 20

PrivateSubWorksheet_Change(ByValTargetAsRange)IfTarget.Address="$J$8"AndTarget="0"The... Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$J$8" And Target = "0" Then ActiveSheet.Shapes("Chart 4").Visible = True
If Target.Address = "$J$8" And Target = "0" Then ActiveSheet.Shapes("Chart 5").Visible = False
If Target.Address = "$J$8" And Target = "0" Then ActiveSheet.Shapes("Chart 6").Visible = False
If Target.Address = "$J$8" And Target = "0" Then ActiveSheet.Shapes("Chart 7").Visible = False
If Target.Address = "$J$8" And Target = "0" Then ActiveSheet.Shapes("Chart 8").Visible = False
If Target.Address = "$J$8" And Target = "1" Then ActiveSheet.Shapes("Chart 4").Visible = False
If Target.Address = "$J$8" And Target = "1" Then ActiveSheet.Shapes("Chart 5").Visible = Ture
If Target.Address = "$J$8" And Target = "1" Then ActiveSheet.Shapes("Chart 6").Visible = False
If Target.Address = "$J$8" And Target = "1" Then ActiveSheet.Shapes("Chart 7").Visible = False
If Target.Address = "$J$8" And Target = "1" Then ActiveSheet.Shapes("Chart 8").Visible = False
If Target.Address = "$J$8" And Target = "2" Then ActiveSheet.Shapes("Chart 4").Visible = False
If Target.Address = "$J$8" And Target = "2" Then ActiveSheet.Shapes("Chart 5").Visible = False
If Target.Address = "$J$8" And Target = "2" Then ActiveSheet.Shapes("Chart 6").Visible = Ture
If Target.Address = "$J$8" And Target = "2" Then ActiveSheet.Shapes("Chart 7").Visible = False
If Target.Address = "$J$8" And Target = "2" Then ActiveSheet.Shapes("Chart 8").Visible = False
这是我看了网上攻略写的,别笑话我,刚学。。。真的不太会
If Target.Address = "$J$8" And Target = "3" Then ActiveSheet.Shapes("Chart 4").Visible = False
If Target.Address = "$J$8" And Target = "3" Then ActiveSheet.Shapes("Chart 5").Visible = False
If Target.Address = "$J$8" And Target = "3" Then ActiveSheet.Shapes("Chart 6").Visible = False
If Target.Address = "$J$8" And Target = "3" Then ActiveSheet.Shapes("Chart 7").Visible = Ture
If Target.Address = "$J$8" And Target = "3" Then ActiveSheet.Shapes("Chart 8").Visible = False
If Target.Address = "$J$8" And Target = "4" Then ActiveSheet.Shapes("Chart 4").Visible = False
If Target.Address = "$J$8" And Target = "4" Then ActiveSheet.Shapes("Chart 5").Visible = False
If Target.Address = "$J$8" And Target = "4" Then ActiveSheet.Shapes("Chart 6").Visible = False
If Target.Address = "$J$8" And Target = "4" Then ActiveSheet.Shapes("Chart 7").Visible = False
If Target.Address = "$J$8" And Target = "4" Then ActiveSheet.Shapes("Chart 8").Visible = Ture

End Sub
展开
 我来答
云南新华电脑学校
2018-11-29 · 百度认证:云南新华电脑职业培训学校官方账号
云南新华电脑学校
云南新华电脑学校是经云南省教育厅批准成立的省(部)级重点计算机专业学校,采用三元化管理模式,教学设备先进,师资雄厚学生毕业即就业,学院引进了电商企业入驻,创建心为电商创业园区,实现在校即创业
向TA提问
展开全部
添加一个按钮吧,
选菜单:视图》工具栏》控件工具箱
点左上角的 三角尺+直尺+笔 的图标,进入设计模式
点“命令按钮”(就是刚才按钮的对下3个,一个按钮模样的键)
在工作表某个位置,如a1单元格上画一个长方形,得到按钮。
选“按钮”点右键,在右键菜单中选“查看代码”
在出现的visual basic 编辑器窗口,右边的代码
Private Sub CommandButton1_Click()

End Sub
在上面两行代码的中间粘贴下面的代码:

If Columns("B:D").EntireColumn.Hidden = False Then
Columns("B:D").EntireColumn.Hidden = True
Else
Columns("B:d").EntireColumn.Hidden = False
End If
Range("A2").Select

返回工作表,点“三角尺”按钮,退出设计模式。

点按钮。
OK。
VB编程解放双手
2018-11-28 · 个人VB爱好者专注vb编程_时效软件
VB编程解放双手
采纳数:1204 获赞数:2391

向TA提问 私信TA
展开全部
Private Sub Worksheet_Change(ByVal Target As Range)
n = ActiveSheet.Shapes.Count
m = ActiveSheet.Range("j8")
For j = 1 To n
If j = m + 1 Then
ActiveSheet.Shapes(j).Visible = True
Else
ActiveSheet.Shapes(j).Visible = False
End If
Next
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式