Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Search and replace using a named array on another worksheet

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Search and replace using a named array on another worksheet

Thanks (again) Tom !!

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
Search a named range rhhince[_2_] Excel Worksheet Functions 1 August 27th 09 06:19 AM
search an array for values contained in another array Cheer-Phil-ly Excel Programming 0 April 12th 07 09:44 PM
Search and replace on the worksheet Jac Tremblay[_4_] Excel Programming 4 January 25th 07 07:40 PM
SEARCH EXCEL ARRAY FOR NON-VOIDS AND ENTER INTO ANOTHER ARRAY, ROSE THE RED Excel Programming 1 December 31st 04 06:01 PM
How do I resize a named array in Excel from a MxN array to a mxn . CymonM Excel Programming 8 September 27th 04 08:29 AM


All times are GMT +1. The time now is 10:46 PM.

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"