Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub ReplaceWithName()
Dim rng as Range, r as Range, cell as Range Dim res as Variant set rng = ActiveWorkbook.Names("EMPLOYEE").ReferstoRange with worksheets("sheet1") set r = .Range(.Cells(2,1),.Cells(rows.count,1).End(xlup)) End with for each cell in r res = application.Vlookup(cell,rng,2,0) if not iserror(res) then cell.Value = res end if Next End Sub -- Regards, Tom Ogilvy "Ixtreme" wrote: Hello, Hopefully somebody can help me with the following: I have a script that imports data from an external source to sheet1. On sheet2 I have named range EMPLOYEE which holds the employee code in columnA and the full name in columnB. What I would like is a vba script to walk through each value in column A on sheet1 to replace the employeecode with the fullname which can be found on sheet2 (EMPLOYEE). (EMPLOYEE is sorted on employeecode). I know how to do this with vlookup, however I would like to have this automated. Thanks, Mark |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks (again) Tom !!
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Search a named range | Excel Worksheet Functions | |||
search an array for values contained in another array | Excel Programming | |||
Search and replace on the worksheet | Excel Programming | |||
SEARCH EXCEL ARRAY FOR NON-VOIDS AND ENTER INTO ANOTHER ARRAY, | Excel Programming | |||
How do I resize a named array in Excel from a MxN array to a mxn . | Excel Programming |