ialexander03
New Member
- Joined
- Jun 9, 2017
- Messages
- 14
Well, I am under no doubt this has been answered a million times, but can I figure it? Hell to the no, is the answer!! So I need your help.
I have created a map of the of South of England, but post code region, which is the important bit, and the reason why I have created one rather than downloading someone elses, as there doesn't seem to be one split by post code, only County/State.
I have the picture pasted onto the sheet, we will use Sheet 1 as its name. And then I have drawn (by eye!!) the regions over the top with autoshape (we will call these Freeform: Shape 1, shape 2 etc etc) to make the map but with auto shapes.
I have tied each shape to its own cell, as, and this is where I am stuck, I planned to use this VBA code to change the shape colour based on the number in the cell:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim shp As Shape, r As Long, g As Long, b As Long
Code:
Dim shp As Shape, r As Long, g As Long, b As Long
With Sheet1
For Each shp In .Shapes
With shp.TextFrame
Select Case .Characters.Text
Case "1"
r = 255
g = 0
b = 0
Case "2"
r = 0
g = 255
b = 0
End Select
End With
shp.Fill.ForeColor.RGB = RGB(r, g, b)
Next shp
End With
BUT, I cannot get it to work for one shape, let alone all 50 something there are! Please can you help me. Tell me if I am wrong totally or just missing one thing! Any help is greatly appreciated
I have created a map of the of South of England, but post code region, which is the important bit, and the reason why I have created one rather than downloading someone elses, as there doesn't seem to be one split by post code, only County/State.
I have the picture pasted onto the sheet, we will use Sheet 1 as its name. And then I have drawn (by eye!!) the regions over the top with autoshape (we will call these Freeform: Shape 1, shape 2 etc etc) to make the map but with auto shapes.
I have tied each shape to its own cell, as, and this is where I am stuck, I planned to use this VBA code to change the shape colour based on the number in the cell:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim shp As Shape, r As Long, g As Long, b As Long
Code:
Dim shp As Shape, r As Long, g As Long, b As Long
With Sheet1
For Each shp In .Shapes
With shp.TextFrame
Select Case .Characters.Text
Case "1"
r = 255
g = 0
b = 0
Case "2"
r = 0
g = 255
b = 0
End Select
End With
shp.Fill.ForeColor.RGB = RGB(r, g, b)
Next shp
End With
BUT, I cannot get it to work for one shape, let alone all 50 something there are! Please can you help me. Tell me if I am wrong totally or just missing one thing! Any help is greatly appreciated