分享 | 可以自动着色的地图教程终于来了!
着色可以自由配置 可以根据省份来着色 可以根据数值大小来自由着色 VBA一键处理!
'公众号:Excel办公实战
'作者:E精精
'功能:地图着色
'日期:20210507
'------------------------------------------------
Sub 地图作色()
'省份所在列-可自由配置
Const strCol As String = "I"
Dim i As Long
With Sheet1
maxRow = .Cells(Rows.Count, strCol).End(3).Row
For i = 2 To maxRow
.Shapes(.Cells(i, strCol)).Fill.ForeColor.RGB = _
.Cells(i, Cells(1, strCol).Column + 2).Interior.Color
Next
End With
End Sub
Sub 清除着色()
Dim Sh As Shape
With ActiveSheet
For Each Sh In .Shapes
If Sh.Type = MsoShapeType.msoFreeform Then
Sh.Fill.ForeColor.RGB = RGB(255, 255, 255)
End If
Next
End With
'公众号:Excel办公实战
'作者:E精精
'功能:RGB地图着色
'日期:20210507
'------------------------------------------------
Sub 地图作色RGB()
'省份所在列-可自由配置
Const strCol As String = "I"
Dim i As Long
With Worksheets("RGB着色")
maxRow = .Cells(Rows.Count, strCol).End(3).Row
For i = 2 To maxRow
arRGB = Split(.Cells(i, Cells(1, strCol).Column + 2), "|")
.Shapes(.Cells(i, strCol)).Fill.ForeColor.RGB = _
VBA.RGB(arRGB(0), arRGB(1), arRGB(2))
Next
End With
End Sub
赞 (0)