Can someone please help with the attached, and code?
I keep getting an error on me.shapes.
I am trying to get the shapes to change colour based on the value in v12:v201 (relative to the key)
Thanks,
Kevin
I keep getting an error on me.shapes.
I am trying to get the shapes to change colour based on the value in v12:v201 (relative to the key)
Thanks,
Kevin
Code:
Private Sub ColorShapes()
Dim shp As Shape
Dim ShapeVal As Variant
Dim PostCodes As Variant
PostCodes = Array("pcPE", "pcCB", "pcIP", "pcNR", "pcCO", "pcSG", "pcMK")
Application.ScreenUpdating = False
For Each shp In Me.Shapes
If Len(shp.Name) <= 7 Then
For i = 0 To UBound(PostCodes, 1)
If shp.Name Like PostCodes(i) & "*" Then
ShapeNum = Val(Application.WorksheetFunction.Substitute(shp.Name, PostCodes(i), ""))
shpname = shp.Name
' insert postcode reference names here and vlook up to postcode reference names here
ShapeVal = Application.Evaluate("=VLOOKUP(" & """" & shpname & """" & " , $u$10:$v$202 , 2 , FALSE)")
If Not VBA.IsError(ShapeVal) Then
' insert vkey values here
IndexVal = Application.Evaluate("=MATCH(" & ShapeVal & " , $v$5:$v$8 , 1)")
ShapeColor = Range("$u$8").Offset(IndexVal - 1).Interior.Color
shp.Fill.ForeColor.RGB = ShapeColor
shp.Fill.Solid
shp.Line.Visible = msoFalse
End If
Exit For
End If
Next
End If
Next
Application.ScreenUpdating = True
End Sub
[CODE]