电脑教程
位置:首页>> 电脑教程>> WPS教程>> excel图表形状怎么设置

excel图表形状怎么设置

  发布时间:2022-10-08 07:15:15 

标签:excel图表,excel图表形状怎么设置,excel怎么设置,WPS

excel图表形状怎么设置?下面再举一个例子,如下图1所示。

excel图表形状怎么设置

图1

对单元格H3设置数据有效性如下图2所示。

excel图表形状怎么设置

图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所示。

excel图表形状怎么设置

图3

0
投稿

猜你喜欢

手机版 电脑教程 asp之家 www.aspxhome.com