如何让excel图表形状生动起来
时间:2022-06-08 04:26:34
下面再举一个例子,如下图1所示。
图1
对单元格H3设置数据有效性如下图2所示。
图2
在形状所在的工作表模块中,输入代码:
Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo errHandler Dim sh As Shape Dim myColor As Long Dim lAdj As Long Set sh = Shapes(“Partial Circle 1”) If Target.Address = “$H$3″ Then Application.EnableEvents = False sh.Adjustments.Item(1) = 0 Select Case Target.Value Case 0: lAdj = 0 Case Else: lAdj = -(360 – (360 * Target.Value)) End Select sh.Adjustments.Item(2) = lAdj ‘修改形状颜色 Select Case Target.Value Case Is >= 0.85: myColor _ = RGB(169, 208, 142) ‘绿色 Case Is >= 0.75: myColor _ = RGB(255, 255, 0) ‘黄色 Case Is >= 0.5: myColor _ = RGB(255, 192, 0) ‘橙色 Case Else: myColor _ = RGB(255, 0, 0) ‘红色 End Select sh.Fill.ForeColor.RGB = myColor End If exitHandler: Application.EnableEvents = True Exit Sub errHandler: MsgBox Err.Number & ” ” &Err.Description GoTo exitHandlerEnd Sub
我们可以添加一小段代码,让这个图动起来,如下图3所示。
图3
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
SUMIFS多字段多条件求和
![](https://img.aspxhome.com/file/2023/7/a142267_0s.png)
word文档如何删除水印?
![](https://img.aspxhome.com/file/2023/3/34693_0s.gif)
office 2016的新增功能PPT篇,你知道几个?
![](https://img.aspxhome.com/file/2023/4/16704_0s.jpg)
按照指定工作表中的数据顺序对另一工作表中的数据排序
![](https://img.aspxhome.com/file/2023/8/a142578_0s.jpg)
如何在Word 2007中插入页码
![](https://img.aspxhome.com/file/2023/1/23761_0s.jpg)
Win10搜索框不能使用了怎么办?
![](https://img.aspxhome.com/file/2023/9/50419_0s.png)
win10开机如何强制进入安全模式?win10开机强制进入安全模式的方法
![](https://img.aspxhome.com/file/2023/7/47757_0s.png)
如何在Word中用一张A4纸上排版8张图片
![](https://img.aspxhome.com/file/2023/2/18222_0s.jpg)
win10网络适配器不见了怎么处理?解决win10网络适配器不见了的方法
![](https://img.aspxhome.com/file/2023/5/47555_0s.png)
Excel2007快速删除重复记录
通过Word文件收集信息 使用Excel自动摘录数据方法
![](https://img.aspxhome.com/file/2023/4/23804_0s.jpg)
Word中进行调节文档图片透明度的设置技巧
用Word列算式 使用内置工具更加方便
在excel表格中怎么居中打印呢?
![](https://img.aspxhome.com/file/2023/1/a141591_0s.jpg)
升级iOS 14预览版后,你都发现了哪些实用小功能?
![](https://img.aspxhome.com/file/2023/4/a194974_0s.png)
Win10电脑玩游戏总是死机?教你一招重置显卡驱动!
![](https://img.aspxhome.com/file/2023/8/49358_0s.jpg)
wps怎么替换回车符号如何把换行符替换为其它符号
![](https://img.aspxhome.com/file/2023/4/a163754_0s.jpg)
Word文件怎么设置不打印出附加信息?
![](https://img.aspxhome.com/file/2023/8/22858_0s.jpg)
excel怎么对单列排序?
![](https://img.aspxhome.com/file/2023/3/36133_0s.jpg)
Word2013怎么取消启用实时预览的功能
![](https://img.aspxhome.com/file/2023/5/18545_0s.jpg)