Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Help with populating a text-box with a pull-down box

Hello all,

I'm working on a web-based form. I am trying to find the source code
for something that will allow me to do the following novel procedure
with a pull-down menu and a text box: There is a pull-down menu, and
another text box right besides the pull-down menu. The pull-down menu
has the names of all the states in the USA in it. When one state is
selected, the text box is automatically populated with the capital of
that state.

In MS Excel, I've created a novel way to handle this issue using
Boolean logic. Unfortunately, I can only have 7 states in my pull-down
menu, and the source code is very unwieldy:

IF(Sheet2!D1=1,Sheet2!A1, IF(Sheet2!$D$1=2,Sheet2!A2,
IF(Sheet2!$D$1=3,Sheet2!A3, IF(Sheet2!$D$1=4,Sheet2!A4,
IF(Sheet2!$D$1=5,Sheet2!A5, IF(Sheet2!$D$1=6,Sheet2!A6,
IF(Sheet2!$D$1=7,Sheet2!A7, IF(Sheet2!$D$1=8,Sheet2!A8))))))))

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Help with populating a text-box with a pull-down box

Set up a lookup table which has each state and its Capital, say on
sheet3 A1:B52. Then you could use a vlookup e.g.

=vlookup(sheet2!d1,sheet3!a1:b52,2,0)

Hope this helps
Rowan

Brablo wrote:
Hello all,

I'm working on a web-based form. I am trying to find the source code
for something that will allow me to do the following novel procedure
with a pull-down menu and a text box: There is a pull-down menu, and
another text box right besides the pull-down menu. The pull-down menu
has the names of all the states in the USA in it. When one state is
selected, the text box is automatically populated with the capital of
that state.

In MS Excel, I've created a novel way to handle this issue using
Boolean logic. Unfortunately, I can only have 7 states in my pull-down
menu, and the source code is very unwieldy:

IF(Sheet2!D1=1,Sheet2!A1, IF(Sheet2!$D$1=2,Sheet2!A2,
IF(Sheet2!$D$1=3,Sheet2!A3, IF(Sheet2!$D$1=4,Sheet2!A4,
IF(Sheet2!$D$1=5,Sheet2!A5, IF(Sheet2!$D$1=6,Sheet2!A6,
IF(Sheet2!$D$1=7,Sheet2!A7, IF(Sheet2!$D$1=8,Sheet2!A8))))))))

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Help with populating a text-box with a pull-down box

Thanks for your guidance. I think I need some guidance with this
function.

Suppose that I have a column of major cities in the USA in column A.
Column B tells me which state that major city is located in. Some of
the data is:

MajCity State
San Jose CA
San Francisco CA
Detroit MI
Boston MA
Albany NY
New York NY

I have a pulldown menu that has a list of all the "MajCity". When the
user selects one of the cities, Albany for example, the output is "NY",
and this is to be displayed in E55.

What's the algorithm for this problem?


Rowan wrote:
Set up a lookup table which has each state and its Capital, say on
sheet3 A1:B52. Then you could use a vlookup e.g.

=vlookup(sheet2!d1,sheet3!a1:b52,2,0)

Hope this helps
Rowan

Brablo wrote:
Hello all,

I'm working on a web-based form. I am trying to find the source code
for something that will allow me to do the following novel procedure
with a pull-down menu and a text box: There is a pull-down menu, and
another text box right besides the pull-down menu. The pull-down menu
has the names of all the states in the USA in it. When one state is
selected, the text box is automatically populated with the capital of
that state.

In MS Excel, I've created a novel way to handle this issue using
Boolean logic. Unfortunately, I can only have 7 states in my pull-down
menu, and the source code is very unwieldy:

IF(Sheet2!D1=1,Sheet2!A1, IF(Sheet2!$D$1=2,Sheet2!A2,
IF(Sheet2!$D$1=3,Sheet2!A3, IF(Sheet2!$D$1=4,Sheet2!A4,
IF(Sheet2!$D$1=5,Sheet2!A5, IF(Sheet2!$D$1=6,Sheet2!A6,
IF(Sheet2!$D$1=7,Sheet2!A7, IF(Sheet2!$D$1=8,Sheet2!A8))))))))


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Help with populating a text-box with a pull-down box

Lets say your dropdown is in cell D55, and as stated your list of cities
is in Column A and the associated state is in Column B.
In E55 enter the formula:

=VLOOKUP(D55,$A:$B,2,0)

This will return a #NA error if D55 is blank or contains a city which is
not in the list in column A. You can get around this by adapting the
formula as follows:

=IF(ISNA(VLOOKUP(D55,$A:$B,2,0)),"",VLOOKUP(D55,$A :$B,2,0))

You can find more info on vlookups in excel help and at
http://www.contextures.com/xlFunctions02.html

Regards
Rowan

Brablo wrote:
Thanks for your guidance. I think I need some guidance with this
function.

Suppose that I have a column of major cities in the USA in column A.
Column B tells me which state that major city is located in. Some of
the data is:

MajCity State
San Jose CA
San Francisco CA
Detroit MI
Boston MA
Albany NY
New York NY

I have a pulldown menu that has a list of all the "MajCity". When the
user selects one of the cities, Albany for example, the output is "NY",
and this is to be displayed in E55.

What's the algorithm for this problem?


Rowan wrote:

Set up a lookup table which has each state and its Capital, say on
sheet3 A1:B52. Then you could use a vlookup e.g.

=vlookup(sheet2!d1,sheet3!a1:b52,2,0)

Hope this helps
Rowan

Brablo wrote:

Hello all,

I'm working on a web-based form. I am trying to find the source code
for something that will allow me to do the following novel procedure
with a pull-down menu and a text box: There is a pull-down menu, and
another text box right besides the pull-down menu. The pull-down menu
has the names of all the states in the USA in it. When one state is
selected, the text box is automatically populated with the capital of
that state.

In MS Excel, I've created a novel way to handle this issue using
Boolean logic. Unfortunately, I can only have 7 states in my pull-down
menu, and the source code is very unwieldy:

IF(Sheet2!D1=1,Sheet2!A1, IF(Sheet2!$D$1=2,Sheet2!A2,
IF(Sheet2!$D$1=3,Sheet2!A3, IF(Sheet2!$D$1=4,Sheet2!A4,
IF(Sheet2!$D$1=5,Sheet2!A5, IF(Sheet2!$D$1=6,Sheet2!A6,
IF(Sheet2!$D$1=7,Sheet2!A7, IF(Sheet2!$D$1=8,Sheet2!A8))))))))



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
How to look up and pull text from another wkst Carolyn Excel Discussion (Misc queries) 1 October 30th 09 07:43 PM
Populating data from a pull down Excel Help Excel Discussion (Misc queries) 1 April 29th 08 09:07 PM
Populating multiple cells from a single pull down [email protected] Excel Discussion (Misc queries) 2 January 10th 07 09:56 PM
Pull-down text in a cell MrSeagull Excel Worksheet Functions 2 October 2nd 05 04:59 AM
populating a cell with text w/ line breaks Nick Hodge Excel Programming 2 July 9th 04 12:19 AM


All times are GMT +1. The time now is 04:52 AM.

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

About Us

"It's about Microsoft Excel"