ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   MACRO Help (https://www.excelbanter.com/excel-discussion-misc-queries/57534-macro-help.html)

DNA

MACRO Help
 
I have several worksheets in a workbook. Each sheet has a column "Part
Number" (in different locations throughout each sheet).

I also have another column "Employee" (which is a number value).

Here's the task: If a part number is 5400 (for example) make the employee
number column 001. Overall, if part number is X, then employee number
automatically pre-fills with an employee number.

Hope this make sense.


SteveG

MACRO Help
 

Assuming that each Part Number has a unique Employee id then you don't
need to use a macro if you don't want. Create a table with Part Number
in column J and corresponding Employee in K. Sort in ascending order by
Part Number.

In your sheet, say your Part Number is input in column A and the
Employee number you want to automatically fill is in column B. In B2.

=VLOOKUP(A2,$J$1:$K$6,2,FALSE)

This looks up the Part Number in A2 and compares it to the table you
created and returns the corresponding Employee number from that table.
For asthetic purposes, hide the columns containing your tables if you
don't want them to be seen. You could also create the table in a
separate worksheet altogether and hide that from view as well. In
order to see the preceding zeros in your results (Employee Id = 001)
format your cells as 000.



Cheers,

Steve


--
SteveG
------------------------------------------------------------------------
SteveG's Profile: http://www.excelforum.com/member.php...fo&userid=7571
View this thread: http://www.excelforum.com/showthread...hreadid=488714



All times are GMT +1. The time now is 02:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com