
excel
vbFunction addTen(cl As Range)Dim RegEx As Object, colSet RegEx = CreateObject("vbscript.RegExp")RegEx.Pattern = "(d+)[^G]"RegEx.Global = TrueSet col = RegEx.Execute(cl.Value)For Each vl In colIf addTen = "" ThenaddTen = cl.ValueaddTen = Replace(addTen, vl.submatches(0), vl.submatches(0) + 10)End IfNextEnd Function这个函数会返回一个新数值,即原始数值加上10。在执行该函数时,请确保输入的参数为一个范围对象,该范围对象包含需要进行加法运算的单元格。如果需要将结果写入到另一个单元格中,请使用excel提供的相关函数来实现。注意:以上代码仅适用于excel 2007及以后版本。对于其他版本,请根据具体情况进行相应调整。Copyright © 2025 IZhiDa.com All Rights Reserved.
知答 版权所有 粤ICP备2023042255号