VBA中的Replace函数用于在字符串中替换指定的子字符串。它的语法如下:
Replace(expression, find, replace[, start[, count[, compare]]])
参数说明:
示例:
Dim originalString As String
originalString = "apple, orange, banana, apple"
Dim newString As String
newString = Replace(originalString, "apple", "pear")
MsgBox newString
以上代码将会弹出窗口显示"pear, orange, banana, pear"。