如何用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 展开
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。
选菜单:视图》工具栏》控件工具箱
点左上角的 三角尺+直尺+笔 的图标,进入设计模式
点“命令按钮”(就是刚才按钮的对下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。
展开全部
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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |