更新时间:2023-02-21 15:47:48
使用公式属性获取字符串值的公式,然后在替换文本后重新分配。
Use the formula property to get the string value of formula in a cell then reassign it after replacing the text.
Dim formulaString as String
formulaString = ThisWorkbook.Sheets(1).Range("A1").Formula
formulaString = Replace(formulaString,"CBK","ALBK")
ThisWorkbook.Sheets(1).Range("A1").Formula = formulaString
浏览工作簿中的每个工作表
To go through each worksheet in your workbook
Dim wb as workbook
Dim i as integer
set wb = thisworkbook 'or whatever you choose to open here
for i = 1 to wb.worksheets.count
wb.sheets(i).range("A1").Formula = Replace(wb.sheets(i).range("A1").Formula,"CBK","ALBK")
next i