Matching Zip Codes to Districts EXL

April 12, 2009 at 07:58:48
Specs: Windows Vista

I'm doing a study of all the 1000 federal housing in the state of Washinton, and I wanted to match up the zip codes associated witht he housing projects to the legislative districts these housing projects belong.

So currently, I have one column with all the federal housing zip codes, and I have 10 columns that represent the 10 district numbers and their respective zip codes associated with each district.

My goal is to have excel automatically assign the district numbers to each of the 1000 federal housing projects.

How do I do that?

Thank You!

See More: Matching Zip Codes to Districts EXL

Report •

April 12, 2009 at 09:26:13

Your zip codes are in A1:A1000
Your district numbers and zip codes are in C1:L100, with the district numbers in A1:L1

Right click the sheet tab for the sheet that contains your data, choose view code and paste this code in.

Adjust your ranges to match your actual data ranges and run it.

Sub Zip_Finder()
'Loop through zip code list
 For Each Zip In Range("A1:A1000")
  With Range("C1:E100")
'Find Zip in District table
   Set District = .Find(Zip, lookat:=xlWhole)
'If found, put value from Row 1 in Column B
    If Not District Is Nothing Then _
       Zip.Offset(0, 1) = Cells(1, District.Column)
  End With
End Sub

Report •
Related Solutions

Ask Question