Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 355
Default Need formula or VBA code

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need formula or VBA code


this looks like a simple lookup formula

here is a great example that shows VLOOKUP

http://www.datapigtechnologies.com/f...s/vlookup.html


--
davesexcel
------------------------------------------------------------------------
davesexcel's Profile: http://www.excelforum.com/member.php...o&userid=31708
View this thread: http://www.excelforum.com/showthread...hreadid=531194

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Need formula or VBA code

With the sample data and =vlookup() that was used in that presentation, I'm kind
of surprised that the formulat wasn't:

=vlookup(a2,key,2,false)
(added the 4th parm)

And maybe a note about changing the format doesn't mean that the underlying
value will change.

To the OP:

You may want to read Debra Dalgleish's notes:
http://www.contextures.com/xlFunctions02.html (for =vlookup())
and
http://www.contextures.com/xlFunctions03.html (for =index(match()))



davesexcel wrote:

this looks like a simple lookup formula

here is a great example that shows VLOOKUP

http://www.datapigtechnologies.com/f...s/vlookup.html

--
davesexcel
------------------------------------------------------------------------
davesexcel's Profile: http://www.excelforum.com/member.php...o&userid=31708
View this thread: http://www.excelforum.com/showthread...hreadid=531194


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Need formula or VBA code

Vlookup won't work in this instance. Instead, you need Index and match.

In A1 of sheet1 put in

=Index(Sheet2!A:A,Match(B1,Sheet2!B:B,0),1)

then drag fill down the column.

If the ID's start in row2 of sheet1


In A2:
=Index(Sheet2!A:A,Match(B2,Sheet2!B:B,0),1)

--
Regards,
Tom Ogilvy



"davesexcel" wrote
in message ...

this looks like a simple lookup formula

here is a great example that shows VLOOKUP

http://www.datapigtechnologies.com/f...s/vlookup.html


--
davesexcel
------------------------------------------------------------------------
davesexcel's Profile:

http://www.excelforum.com/member.php...o&userid=31708
View this thread: http://www.excelforum.com/showthread...hreadid=531194



  #5   Report Post  
Posted to microsoft.public.excel.programming
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





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 355
Default Need formula or VBA code

Thanks All!!
--
Sandy


"Sandy" wrote:

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

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
formula or vba code Nader Excel Worksheet Functions 14 August 16th 06 10:54 AM
Help with Formula in Code Juan Excel Programming 1 March 27th 06 06:36 PM
formula through vb code Jonsson[_48_] Excel Programming 4 September 19th 05 11:30 AM
Add formula in the code Annette[_5_] Excel Programming 3 February 21st 05 08:19 PM
Formula or code Jim[_15_] Excel Programming 0 July 9th 03 05:51 PM


All times are GMT +1. The time now is 12:07 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"