Highlighting postcodes on a map

monkeyharris

Active Member
Joined
Jan 20, 2008
Messages
368
Office Version
  1. 365
Platform
  1. Windows
Dear all,

I have a postcode map that shows UK postcodes inside each zone and a corresponding list.
There is a search field where the user enters the postcode and what i want is for the corresponding map square to change colour for easy and quick reference to where it is.
Under this i know how to make a field show which branch is closest to the chosen postcode, i'm just struggling with how to make the image change colour. I couldn't copy the map into a mini sheet so attached an image.

IDS Postcode Map.xlsx
TUVWXY
56
57Enter PostcodeRHSwindonRG
58IDS BranchSwindonSL
59SwindonOX
60WoodfordCM
61WoodfordRM
62WoodfordSG
General Tariff
 

Attachments

  • Map.PNG
    Map.PNG
    98.3 KB · Views: 13
Opps! Just noticed that the above code has my test entry cell reference of V5 rather than your desired V57
Just edit that line as below
VBA Code:
 If Intersect(Range("V57"), Target) Is Nothing Then Exit Sub
Hi,
I know i'm doing something wrong. I've put the code in the worksheet and made the amendment to V57. I enter CT in V57 and nothing happens.
Do i need to do something with the images? At the moment they are saved in a file called CT, DA, ME etc then placed in the workbook.
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Opps! Just noticed that the above code has my test entry cell reference of V5 rather than your desired V57
Just edit that line as below
VBA Code:
 If Intersect(Range("V57"), Target) Is Nothing Then Exit Sub
Morning,
I must be doing something wrong as i put the code in the worksheet VBA window, made the amendment to V57, but when i enter a postcode in V57 nothing happens.
Is there something special i need to do to each drawing/Postcode image?
 
Upvote 0
@monkeyharris I had assumed that your postcode elements would be shapes similar to map element shapes that were in a post I responded to a couple of weeks back.
Colour of shape not changing
I'm not sure I have an immediate answer given that your postcode elements are images. I assume transparent backgrounds?

I will give it some thought and get back to you if I feel I can help.
 
Upvote 0
@monkeyharris. Did you get to sort this?
I have had no luck in coding to change a picture colour in the same way as works with shapes.
I do however have a bit of an idea if you are still wanting to pursue it?
 
Upvote 0
@monkeyharris. Did you get to sort this?
I have had no luck in coding to change a picture colour in the same way as works with shapes.
I do however have a bit of an idea if you are still wanting to pursue it?
Hi Snakeips,

I certainly do want to pursue it. If there is something different i need to do or obtain another type of map that would be fine.
 
Upvote 0
@monkeyharris In the light of my new understanding re entry cell being V61 etc I now propose the following modified code.

VBA Code:
Sub Worksheet_Change(ByVal Target As Range)
Dim NewCode As String

    ' Check if 'Target' is the Entry cell entry cell V61
    'If not then exit , do nothing
    If Intersect(Range("V61"), Target) Is Nothing Then Exit Sub
    Debug.Print Target.Cells.Count
    If Target.Cells.Count > 1 Then Exit Sub
    
 'Otherwise
 On Error Resume Next 'ignore errors if code not valid shape name
 'reset default colours
 ActiveSheet.Shapes("UKGroup").Fill.ForeColor.RGB = vbWhite
 ActiveSheet.Shapes("CLonGroup").Fill.ForeColor.RGB = vbRed
 ActiveSheet.Shapes("LondonGroup").Fill.ForeColor.RGB = vbRed
' lookup get area shape name
NewCode = Evaluate("=VLOOKUP(V61,'Postcode Districts'!$A$2:$C$2993,2)")
 Application.ScreenUpdating = False
 Application.EnableEvents = False
      
'make selectedsegment green
If NewCode <> "" Then ActiveSheet.Shapes(NewCode).Fill.ForeColor.RGB = vbGreen

On Error GoTo 0  'reset error default
 Application.ScreenUpdating = True
 Application.EnableEvents = True

End Sub
HTH
 
Upvote 0

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top