View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Arvi Laanemets Arvi Laanemets is offline
external usenet poster
 
Posts: 99
Default Need formula or VBA code

Hi

The easiest solution is to redesign the sheet 2 so, that employee nimbers
are in column A, and employee names in column B (simply move names column to
right of numbers column, and delete empty column from left). This allows you
to use VLOOKUP to get employee name from its number - otherwise you have to
use more complex formulas.

Now define a dynamic named range EmployeeTable on Sheet 2 (I assume the 1st
row contains column headers)
=OFFSET('Sheet 2'!$A$1,1,,COUNTA('Sheet 2'!$A:$A)-1,2)
(This named range refers always to whole table, when you add or delete
employees - lest you don't have empty rows there. You can skp this part, and
use common range reference in following formula instead, when you have any
difficultis with it.)

On sheet 1 to you use VLOOKUP formula like this
=VLOOKUP($A2,EmployeeTable,2,0)



Arvi Laanemets



"Sandy" wrote in message
...
Hello -

I need a formula or code for the following scenario:

Sheet 2 has two columns; one with the name (A) and one with the employee
number (B).

Sheet 1 has many columns, but the ones I'm concerned with are Employee

Name
(Column A - value I need to look up and insert) and the employee number in
Column B.

I would like to look up the employee number on Sheet 2, column B, then

take
the corresponding employee name from Sheet2 Column A and put it into

Sheet1,
Column A.

Any help will be greatly appreciated!

--
Sandy