Hi all, I am very new to VBA code and attempting to create a color coded heat map based on the user selecting criteria from slicers/pivot table. I am looking to have my code run automatically when someone opens the file, and the shapes on the map (county names) will automatically change color based on a cell's number value. i.e. if a shape's value is 0.15 the color of that shape will change to yellow based on the user's selection in slicers.
below is my code, and like I mentioned, I am first timer in attempting to write and execute so any help is greatly appreciated. The error keeps popping up on the 4th line of 'For Each shp In Sheets("WBIN Map"). error is object doesn't support this property or method. i am using excel 2013
below is my code, and like I mentioned, I am first timer in attempting to write and execute so any help is greatly appreciated. The error keeps popping up on the 4th line of 'For Each shp In Sheets("WBIN Map"). error is object doesn't support this property or method. i am using excel 2013
Code:
Sub WBINmap()
' WBINmap Macro
Dim shp As Shape
For Each shp In Sheets("WBIN Map")
If Range("G106:G121") <= 0 Then
ActiveSheet.Shapes.Range(Array("Barnstable", "Belknap", "Cheshire", "Dukes", "Essex", "Hillsborough", "Merrimack", "Middlesex", "Nantucket", "Norfolk", "Plymouth", "Rockingham", "Strafford", "Suffolk", "Windham", "Worcester").Fill.ForeColor.RGB = RGB(192, 192, 192)).Transparency = 0.1999999881
End If
Next
For Each shp In Sheets("WBIN Map")
If Range("G66:G81") = 0.001 - 0.01 Then
ActiveSheet.Shapes.Range(Array("Barnstable", "Belknap", "Cheshire", "Dukes", "Essex", "Hillsborough", "Merrimack", "Middlesex", "Nantucket", "Norfolk", "Plymouth", "Rockingham", "Strafford", "Suffolk", "Windham", "Worcester").Fill.ForeColor.RGB = RGB(255, 255, 178)).Transparency = 0.1999999881
End If
Next
For Each shp In Sheets("WBIN Map")
If Range("G66:G81") = 0.012 - 0.05 Then
ActiveSheet.Shapes.Range(Array("Barnstable", "Belknap", "Cheshire", "Dukes", "Essex", "Hillsborough", "Merrimack", "Middlesex", "Nantucket", "Norfolk", "Plymouth", "Rockingham", "Strafford", "Suffolk", "Windham", "Worcester").Fill.ForeColor.RGB = RGB(254, 204, 92)).Transparency = 0.1999999881
End If
Next
For Each shp In Sheets("WBIN Map")
If Range("G66:G81") = 0.051 - 0.1 Then
ActiveSheet.Shapes.Range(Array("Barnstable", "Belknap", "Cheshire", "Dukes", "Essex", "Hillsborough", "Merrimack", "Middlesex", "Nantucket", "Norfolk", "Plymouth", "Rockingham", "Strafford", "Suffolk", "Windham", "Worcester").Fill.ForeColor.RGB = RGB(253, 141, 60)).Transparency = 0.1999999881
End If
Next
For Each shp In Sheets("WBIN Map")
If Range("G66:G81") = 0.101 - 0.18 Then
ActiveSheet.Shapes.Range(Array("Barnstable", "Belknap", "Cheshire", "Dukes", "Essex", "Hillsborough", "Merrimack", "Middlesex", "Nantucket", "Norfolk", "Plymouth", "Rockingham", "Strafford", "Suffolk", "Windham", "Worcester").Fill.ForeColor.RGB = RGB(240, 59, 32)).Transparency = 0.1999999881
End If
Next
For Each shp In Sheets("WBIN Map")
If Range("G66:G81") >= 0.181 Then
ActiveSheet.Shapes.Range(Array("Barnstable", "Belknap", "Cheshire", "Dukes", "Essex", "Hillsborough", "Merrimack", "Middlesex", "Nantucket", "Norfolk", "Plymouth", "Rockingham", "Strafford", "Suffolk", "Windham", "Worcester").Fill.ForeColor.RGB = RGB(189, 0, 38)).Transparency = 0.1999999881
End If
Next
End Sub
[code]