等值线,颜色和数据

时间:2016-07-08 11:51:18

标签: excel vba excel-vba

我正在尝试仪表板/等值线。我从here.

下载了欧洲版

我会保持简单,我想做的第一件事就是改变灰色和黑色。蓝色。谁能帮忙?模板附带的代码位于

之下
Option Explicit

Function udf_RGB(myR As Byte, myG As Byte, myB As Byte) As Long

  udf_RGB = RGB(myR, myG, myB)

End Function

Sub CheckColor(myCell As Range, myNameToShape As String, myValueToColor As String)
Dim myShape As Shape
Dim myTargetCell As Range
Dim myColorCode As Long

On Error GoTo Catch
  Set myTargetCell = Range(myNameToShape).Columns(1).Find(myCell.Name.Name, LookAt:=xlWhole)
  Set myShape = Sheets(1).Shapes(myTargetCell.Offset(0, 1))
  GoTo Finally

Catch:
  Exit Sub
Finally:

  On Error GoTo 0

  If myCell.Value < Range(myValueToColor).Cells(2, 1).Value Then
    myColorCode = Range(myValueToColor).Cells(1, 2).Value
  Else
    myColorCode = Application.WorksheetFunction.VLookup(myCell.Value, Range(myValueToColor), 2, True)
  End If

  myShape.Fill.ForeColor.RGB = myColorCode

End Sub

Sub UpdateMap()
Dim myCell As Range

  Application.ScreenUpdating = False

  For Each myCell In Range("MapNameToShape").Columns(1).Cells
     CheckColor Range(myCell.Value), "MapNameToShape", "MapValueToColor"
  Next myCell

  Application.ScreenUpdating = True

End Sub

1 个答案:

答案 0 :(得分:0)

一种廉价的方式,但如果你改变这一行

udf_RGB = RGB(myR, myG, myB)

udf_RGB = RGB(myR, myG, 255)

它将用蓝色代替黑色。