鼠标移至工作表标签名处,右键,查看代码,将下列代码粘贴进去
Sub 替换()
For i = 1 To [H65536].End(xlUp).Row
Cells(i, 8).Replace What:="beijing", Replacement:="北京"
Cells(i, 8).Replace What:="shanghai", Replacement:="上海"
Cells(i, 8).Replace What:="xinjiang", Replacement:="新疆"
Cells(i, 8).Replace What:="", Replacement:="江西"
Next
End Sub
退出VB窗口,ALT+F8,运行替换宏。
不用宏也可以,新建一列,如H列后一列I
I2中输入
=if(H2="", "江西", vlookup(H2, {"beijing","北京"; "shanghai","上海"; "xinjiang", "新疆"}, 2))
往下拖动公式
然后复制I列数据,选择粘贴(数值)到H列 即可