How do I set up a default zip code that correspondes to a town?

T

Tarandon

Hi - I am currently entering data into excel for my brothers company such as
the name, address, and phone number of the customer. I am wondering if it is
possible to create a default zip code and area code for each town that I
enter. For example if I enter Huntley, IL. as the town is it possible that
the area code 630 and the zip code 60142 would automatically be entered in
the appropiate column? I am using office 3000. Thanks in advance.....
 
A

AA2e72E

Wow! Even Office 3000 can't anticipate what you want to achieve!

Seriously, look up VLookup & HLookup in the help files; the columns
containing the zip & area code will be formulae. You might hold the table of
town, zip, area in a hidden sheet.
 
P

protonLeah

A possible solution is to put the towns, zip and area codes on a
separate sheet in cols A, B & C. Then, on the main data sheet add a
combo box and select its input range as the column of towns. For the
linked cell choose a cell, D1, maybe. Next, copy the code below to the
"main" sheet:
--------------------------------------------
Sub insert()
Dim sTown As String, sZip As String
Dim Area As String, sPasteAddress As String
Dim iNdx As Integer

Sheets("main").Select
sPasteAddress = ActiveCell.Address
'
'go to "towns" and copy based on index of item selected in combo box
'
Sheets("towns").Select
With ActiveSheet
Application.Goto reference:="R1C4"
iNdx = ActiveCell.Value
sTown = .Cells(iNdx, 1).Value
sZip = .Cells(iNdx, 2).Value
sArea = .Cells(iNdx, 3).Value
End With
'
' Return to "main" and paste
'
Sheets("main").Select
Range(sPasteAddress).Select
With ActiveCell
..Value = sTown
..Offset(0, 1).Value = sArea
..Offset(0, 2).Value = sZip
End With

End Sub
---------------------------------------------------
Back on your main data sheet, add a pushbutton and assign the macro to
it.

In order for this to work, simply select the cell on the main sheet for
the town name, select the town from the combo box and press insert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top