![]() |
automatically insert town name after entering zip code
I have created a sheet in which I am entering addresses. I created a drop
down list for the seven zip codes I am working with. Is there a way to have excel automaticall y enter the corresponding town in the adjacent cell after I choose a zip code? |
Sure. You need a worksheet with the zips and towns listed on it, then you
can use a vlookup. See this for a tutorial: http://www.officearticles.com/tutori...excel.htm#boss ******************* ~Anne Troy www.OfficeArticles.com "accessnovice" wrote in message ... I have created a sheet in which I am entering addresses. I created a drop down list for the seven zip codes I am working with. Is there a way to have excel automaticall y enter the corresponding town in the adjacent cell after I choose a zip code? |
Well it depends:
if it's a fixed cell, you may put a formula in the next cell ( a match / indirect couple OR a lookup function) But you want this even with new lines, you'll need a vba code to auto-add the new next-cell too: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Column = 3 Then ' I suppose you enter zip in the column 3 Dim i& On Error Resume Next Application.EnableEvents = False i = 0 ' below I suppose all the known ZIP code are in the column A ' if unknown, match gives an error ' so i=0 because of "on error resume next" i = Application.WorksheetFunction.Match(Target.Value, Range("A:A"), 1) ' below I suppose the associated Known City are in the B column (column=2) ' and i suppose the city name must be on the right of the entered zip code If i 0 Then: Target.Offset(0, 1).Value = Cells(i, 2) Application.EnableEvents = True End If End Sub |
All times are GMT +1. The time now is 03:27 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com