对于那些使用过主题式(choropleth)的人来说,有没有人把它变成“动态的?”
我已经通过将每个州的生产数据与美国地图联系起来,创建了一个VBA主题地图。然而,结果是一个静态映射,它只显示一个数据集(在本例中,所有州每年都显示)。
代码如下:
Dim y
Dim T1 As Long
Dim T2 As Long
Dim T3 As Long
Dim T4 As Long
Dim T5 As Long
y = 1
T1 = 0
T2 = 5
T3 = 10
T4 = 15
T5 = 20
For Each cell In ActiveSheet.Range("C6:C53") 'The data points on each state for the year 2009, where columns D, E, F, G are 2010, 2011, 2012, 2013, respectively.
If cell.Value = T1 Then
Sheets("Map").Shapes(y).Fill.ForeColor.RGB = RGB(255, 255, 255)
ElseIf cell.Value <= T2 And cell.Value > T1 Then
Sheets("Map").Shapes(y).Fill.ForeColor.RGB = RGB(250, 249, 232)
ElseIf cell.Value <= T3 And cell.Value > T2 Then
Sheets("Map").Shapes(y).Fill.ForeColor.RGB = RGB(247, 245, 218)
ElseIf cell.Value <= T4 And cell.Value > T3 Then
Sheets("Map").Shapes(y).Fill.ForeColor.RGB = RGB(237, 233, 180)
ElseIf cell.Value <= T5 And cell.Value > T4 Then
Sheets("Map").Shapes(y).Fill.ForeColor.RGB = RGB(232, 226, 140)
ElseIf cell.Value > T5 Then
Sheets("Map").Shapes(y).Fill.ForeColor.RGB = RGB(224, 216, 96)
End If
y = y + 1
Next我添加了一个滚动条,其中2009是最小值,2013是最大值,它将滚动的值链接到一个单元格(比如,单元格C30)。
我想通过滚动条来自动化地图,并让地图根据链接的单元格(C30)“移动”每一年的数据集。
这个是可能的吗?在座的任何人都有办法解决这个问题吗?
发布于 2014-09-30 14:59:37
我可以工作,如果你可以给我一个样本的excel工作,你已经工作到目前为止。请以附件形式发送到电子邮件id : summer12in@yahoo.com
谢谢..。
https://stackoverflow.com/questions/26103154
复制相似问题