Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1936|回复: 4

[已解决]求单击按钮后,所有图形都清除掉的代码!

[复制链接]
发表于 2015-8-1 13:49 | 显示全部楼层 |阅读模式
求单击按钮后,所有图形都清除掉的代码!


最佳答案
2015-8-1 14:45
Private Sub CommandButton1_Click()
    Dim x
    For Each x In Me.Shapes
        'Debug.Print x.Name, x.Type
        If x.Type <> 12 Then x.Delete
    Next x
End Sub

求助2.rar (38.67 KB, 下载次数: 7)

求助.zip

40.25 KB, 下载次数: 7

发表于 2015-8-1 14:07 | 显示全部楼层
  1. Private Sub CommandButton1_Click()
  2.     Shapes.SelectAll
  3.     Selection.Delete
  4. End Sub
复制代码
回复

使用道具 举报

 楼主| 发表于 2015-8-1 14:35 | 显示全部楼层
这个代码把按钮也清除了,呵呵。
回复

使用道具 举报

 楼主| 发表于 2015-8-1 14:36 | 显示全部楼层
我要求的是保留按钮,只清除按钮外的图形。
回复

使用道具 举报

发表于 2015-8-1 14:45 | 显示全部楼层    本楼为最佳答案   
Private Sub CommandButton1_Click()
    Dim x
    For Each x In Me.Shapes
        'Debug.Print x.Name, x.Type
        If x.Type <> 12 Then x.Delete
    Next x
End Sub

求助2.rar (38.67 KB, 下载次数: 7)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-19 18:43 , Processed in 0.588440 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表