在Excel中如何使用库search和replace列上的string

我有这个大型的Excel电子表格大约10,000行和5,000个独特的ID。 我想要做一个search和replace,这是基于一个数据库。

从:

在这里输入图像说明

在这里输入图像说明

至:

在这里输入图像说明

我知道这可以通过使用快速search并在Excel中进行replace来完成,但是如果数据有大约5,000个独特的agent-id,那么这可能是一项艰巨的任务。

任何人都有明确的build议?

提前致谢!

这里有一些VBA,它将根据另一个表中的值列表在一张表中find并replace。

Sub multiFindandReplace() Dim myList, myRange Set myList = Sheets("config").Range("A1:B9") Set myRange = Sheets("Sheet1").Range("B2:I1000") For Each cel In myList.Columns(1).Cells myRange.Replace What:=cel.Value, Replacement:=cel.Offset(0, 1).Value, LookAt:=xlPart Next cel End Sub 

这是在sheet1中search单元格B2:I1000。 configuration表包含2列,在列A中查找的值,如果find它们,则将用该列的值B中的值replace它们。

我能够做一个vbmacros代码来完成我所需要的。 我可能需要调整一些特定的单元格,但现在可以使用。

 Sub FindAndReplace() ' FindAndReplace Macro ' @author Louie Miranda ' Ability to find the range of ids against another worksheet ' and insert the name on the main sheet ' ' Loop over the current worksheet For Each c In Worksheets("RECORDS").Range("A3:A7").Cells ' Go to Agents sheet Sheets("AGENTS").Select ' Do a search Cells.Find(What:=c, After:=ActiveCell, LookIn:=xlFormulas, LookAt _ :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _ False, SearchFormat:=False).Activate Application.CutCopyMode = False ' Choose beside the column to copy ActiveCell.Offset(rowOffSet:=0, columnOffset:=-1).Activate Selection.Copy ' Back to records sheet Sheets("RECORDS").Select ' Paste on the current row, plus arrange on which row/offset Range(c.Address).Offset(0, 1).Select ActiveSheet.Paste Next c End Sub