Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Filling Zip by City

How do code to Fill Cells "Zip" by entering the city name in previous cell?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Filling Zip by City

First of all, you would need some table of the various cities and
their zip codes (and this assumes that there is but one zip code per
city). Suppose that data table is in K1:L100, with city names in
column K and zip codes in column L. Then, you could use the VLOOKUP
function to loop up the city in column K and get the corresponding zip
code from column L. If your city names that need zip codes assigned to
them are in A1:A100, enter

=VLOOKUP(A1,K$1:L$100,2,FALSE)

in cell B1 and fill down to B100.

You should probably provide more detail about what you have and what
you need to do.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Tue, 11 Nov 2008 10:12:02 -0800, Perry
wrote:

How do code to Fill Cells "Zip" by entering the city name in previous cell?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Filling Zip by City

I have a customer spreadsheet and I would like the Zip column to
automatically fill when I enter a City in the City Column. I tried writing a
module to do this but it does not work. I used a series of IF then
Statements to define Cities and zip codes. And I defined the variables as
strings.

If City="CityName" then Zip = "zipcode"

I did not use any cities that had multiple zip codes. That comes Later :)
Thnx Perry

"Chip Pearson" wrote:

First of all, you would need some table of the various cities and
their zip codes (and this assumes that there is but one zip code per
city). Suppose that data table is in K1:L100, with city names in
column K and zip codes in column L. Then, you could use the VLOOKUP
function to loop up the city in column K and get the corresponding zip
code from column L. If your city names that need zip codes assigned to
them are in A1:A100, enter

=VLOOKUP(A1,K$1:L$100,2,FALSE)

in cell B1 and fill down to B100.

You should probably provide more detail about what you have and what
you need to do.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Tue, 11 Nov 2008 10:12:02 -0800, Perry
wrote:

How do code to Fill Cells "Zip" by entering the city name in previous cell?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Filling Zip by City

You will need to use the worksheet's Change event... check that the
Target.Column is the same as the column where your **cities** are typed in
and, if it is, then look up the zip code and put it into the appropriate
column where your zip codes go (on the same row as the Target).

--
Rick (MVP - Excel)


"Perry" wrote in message
...
I have a customer spreadsheet and I would like the Zip column to
automatically fill when I enter a City in the City Column. I tried
writing a
module to do this but it does not work. I used a series of IF then
Statements to define Cities and zip codes. And I defined the variables as
strings.

If City="CityName" then Zip = "zipcode"

I did not use any cities that had multiple zip codes. That comes Later :)
Thnx Perry

"Chip Pearson" wrote:

First of all, you would need some table of the various cities and
their zip codes (and this assumes that there is but one zip code per
city). Suppose that data table is in K1:L100, with city names in
column K and zip codes in column L. Then, you could use the VLOOKUP
function to loop up the city in column K and get the corresponding zip
code from column L. If your city names that need zip codes assigned to
them are in A1:A100, enter

=VLOOKUP(A1,K$1:L$100,2,FALSE)

in cell B1 and fill down to B100.

You should probably provide more detail about what you have and what
you need to do.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Tue, 11 Nov 2008 10:12:02 -0800, Perry
wrote:

How do code to Fill Cells "Zip" by entering the city name in previous
cell?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Filling Zip by City

The VLOOKUP approach is still feasible. If you Cities are in column A
and you have the city and zip code pair in columns K:L on Sheet2,
enter the following formula in A1 and fill down as necessary:

=IF(A1="","",VLOOKUP(A1,Sheet2!K1:L1000,2,FALSE))

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Tue, 11 Nov 2008 10:59:06 -0800, Perry
wrote:

I have a customer spreadsheet and I would like the Zip column to
automatically fill when I enter a City in the City Column. I tried writing a
module to do this but it does not work. I used a series of IF then
Statements to define Cities and zip codes. And I defined the variables as
strings.

If City="CityName" then Zip = "zipcode"

I did not use any cities that had multiple zip codes. That comes Later :)
Thnx Perry

"Chip Pearson" wrote:

First of all, you would need some table of the various cities and
their zip codes (and this assumes that there is but one zip code per
city). Suppose that data table is in K1:L100, with city names in
column K and zip codes in column L. Then, you could use the VLOOKUP
function to loop up the city in column K and get the corresponding zip
code from column L. If your city names that need zip codes assigned to
them are in A1:A100, enter

=VLOOKUP(A1,K$1:L$100,2,FALSE)

in cell B1 and fill down to B100.

You should probably provide more detail about what you have and what
you need to do.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Tue, 11 Nov 2008 10:12:02 -0800, Perry
wrote:

How do code to Fill Cells "Zip" by entering the city name in previous cell?




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
city st zip cells Joanne[_4_] Excel Programming 8 September 22nd 06 03:18 PM
1 will be City, 2 will be Roskill and so on please. Steved Excel Worksheet Functions 4 August 16th 05 03:26 AM
1=City, 2=Roskill Steved Excel Worksheet Functions 8 August 16th 05 03:19 AM
filling information from one cell and filling another. Dianne Excel Worksheet Functions 1 August 15th 05 08:14 PM
How do I insert a city map? By Excel Worksheet Functions 1 April 18th 05 11:11 PM


All times are GMT +1. The time now is 10:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"