Replacing imported database value with text

M

marczg

I've been tasked with creating a series of excel reports drawing dat
from a fairly large database. So far I've been successful, but ther
is one function that I can't figure out.

One table of the database contains registration information fo
classes. The classes are only listed as classid=1, classid=2, etc.
have another table in the database that lays out the relationship
1="How to do X", 2="How to do Y".

How would I set up a function so that classid could equal the tex
value associated with it in the other table?

Meaning, right now I can do this


ID | USERNAME | CLASSID | SPECIAL NOTES
---|----------|---------|---------------------
11 | James P. | 1232334 | James likes tofu
12 | James X. | 4445554 | James HATES tofu
13 | David K. | 4445554 | David makes tofu




Since I have a text value for 1232334 in another table (either i
another sheet, or hidden, doesn't matter to me),

CLSNAME | CLASSID
--------|-----------
Typing2 | 1232334
Typing3 | 1232554
Excel10 | 4445554



Can I set up a formula that would automatically replace 1232334 wit
the name of the class?

Like this:


ID | USERNAME | CLSNAME | SPECIAL NOTES
---|----------|---------|---------------------
11 | James P. | Typing2 | James likes tofu
12 | James X. | Excel10 | James HATES tofu
13 | David K. | Excel10 | David makes tofu



There are approximately 100 values for CLASSID and 100 correspondin
values for CLSNAME, but unfortunately the section of the database tha
records registrants for classes only records the CLASSID. I couldn'
figure out an IF statement that wasn't insanely complicated an
incredibly faulty.

Any ideas?

Is this something that I would have to take care of in a MSAcces
Query? Because if so, I don't know how to do that either! HELP!

mar
 
P

Paul Corrado

If you switch the columns in your table with the ClassID and ClassName you
can use a VLOOKUP formula in an new column to return the class name based on
the class ID

=VLOOKUP("classid","range of entire table",2,FALSE)

replace "classid" with the reference to the cell with the Class ID

Replace "range of entire table" with the actual range of the table and use
$'s signs to hold the row and column references constant ($A$1:$B$4 instead
of A1:B4) so the formula can be copied.

If you don't want to see the class ID column, either move it to the leftmost
column and exclude from the print range, or hide it.

HTH

PC
 

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