全部版块 我的主页
论坛 提问 悬赏 求职 新闻 读书 功能一区 学习笔记1.0
1134 1
2015-11-02
Substitute函数每次只能对单个字符或字符串进行替换,如果要对某个目标字符串替换两个以上的内容,需要使用Substitute函数的嵌套。

     要能够进行多重替换,可以编制自定义函数,参考以下代码:

  • 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

[color=rgb(51, 102, 153) !important]复制代码



使用效果如下:


附件下载:【非常有用的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

    [color=rgb(51, 102, 153) !important]复制代码
  • [color=rgb(51, 102, 153) !important]


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2015-11-2 23:46:28
要能够进行多重替换,可以编制自定义函数,参考以下代码
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群