要能够进行多重替换,可以编制自定义函数,参考以下代码:
- Function Subst(ParamArray arglist()) As String
- Text = arglist(0)
- For i = 1 To UBound(arglist) - 1 Step 2
- Text = Replace(Text, arglist(i), arglist(i + 1))
- Next i
- Subst = Text
- End Function
使用效果如下:
附件下载:【非常有用的Excel自定义函数】
Vlookup函数和Hlookup函数在进行查询时,必须以Table_array的首行或首列作为查询对象所在的基准位,当数据表中存在多个列标题或行标题时,使用上述两个函数进行查询就不太方便。
要制作没有限定查询位置的自定义函数,可参考如下代码:
- 复制代码
- Function xlookup(lookupvalue, table_array As Range, Optional index = 1, Optional opt = 0)
- For Each i In table_array
- If i.Value = lookupvalue Then
- If opt = 1 Then
- xlookup = i.Offset(index, 0).Value
- Else
- xlookup = i.Offset(0, index).Value
- End If
- End If
- Next
- End Function
- Function xlookup(lookupvalue, table_array As Range, Optional index = 1, Optional opt = 0)



雷达卡



京公网安备 11010802022788号







