数量太多的话,把不一样的地方提取出来做二维数组,一样的地方用循环结构。
不会VBA,但是我写一个JSA给你看看,但凡学过一点编程思路都一样,自己照着改吧。
function 复数内置替换(){
Selection.Replace("张三","金", xlPart, xlByRows, false, false, true, true);
Selection.Replace("李四","木", xlPart, xlByRows, false, false, true, true);
Selection.Replace("王五","水", xlPart, xlByRows, false, false, true, true);
Selection.Replace("世界","火", xlPart, xlByRows, false, false, true, true);
Selection.Replace("日本","土", xlPart, xlByRows, false, false, true, true);
Selection.Replace("欧洲","阴", xlPart, xlByRows, false, false, true, true);
Selection.Replace("地球","阳", xlPart, xlByRows, false, false, true, true);
}
function 数组替换(){
const a=[
["张三" ,"金"],
["李四" ,"木"],
["王五" ,"水"],
["世界" ,"火"],
["日本" ,"土"],
["欧洲" ,"阴"],
["地球" ,"阳"]
];
for (var i=0;i<a.length;i++)
{
Selection.Replace(a[i][0],a[i][1], xlPart, xlByRows, false, false, true, true);
}
} |