我在电子表格中有多个单元格,在单个单元格中列出两个字符国家ISO代码,如下所示:
CA, MX, US
CA, MX, US
CA, CR, MX, US
AD, AE, AR, AT, AU, BD, BE, BG, BO, BR, CH, CI, CL
CA, MX, US
GB, US
我有另一张表,列出了ISO代码和完整的国家/地区名称。
我想用完整的国家/地区名称替换ISO代码。
有没有人有任何关于如何解决这个问题的建议?
答案 0 :(得分:0)
您可以按照以下方式尝试使用VBA(如果发生任何问题,您应备份文件)
1.按Alt + F11打开VBA
2.传递代码如下
Sub Multi_FindReplace()
Dim sht As Worksheet
Dim fndList As Variant
Dim rplcList As Variant
Dim x As Long
fndList = Array("CA", "MX", "US")
rplcList = Array("canada", "mexico", "usa")
'Loop through each item in Array lists
For x = LBound(fndList) To UBound(fndList)
'Loop through each worksheet in ActiveWorkbook
For Each sht In ActiveWorkbook.Worksheets
sht.Cells.Replace What:=fndList(x), Replacement:=rplcList(x), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
Next sht
Next x
End Sub
3。另存为xlsm
4.运行命令(在VBA中,按F5)
5.完成
注意:
fndList = Array("CA", "MX", "US")
rplcList = Array("canada", "mexico", "usa")
你必须在这里添加所有ISO和contries(使用Vlooup和" Concatenate"函数快速处理以生成此字符串) 供您参考:http://www.thespreadsheetguru.com/the-code-vault/2014/4/14/find-and-replace-all