VBA制作数据地图,调试运行没有报错,点击相关按钮,没有颜色显示。
Option Explicit
Sub fill_color()
Dim i%, c As Long
For i = 2 To 35 '位数据源的起始行和结束行行号,根据区域的多少来确定
Select Case Cells(i, 33)
Case Is >= Range("AK12")
c = Range("AJ12").Interior.Color
Case Range("AK13") To Range("AK12")
c = Range("AJ13").Interior.Color
Case Range("AK14") To Range("AK13")
c = Range("AJ14").Interior.Color
Case Range("AK15") To Range("AK14")
c = Range("AJ15").Interior.Color
Case Else
c = Range("AJ16").Interior.Color
End Select
'Sheet1.Shapes("图形2").Activate
ActiveSheet.Shapes(Cells(i, 32)).Fill.ForeColor.RGB = c
Next
End Sub