修改Execl中sheet名的指定字符串为指定字符串

Sub test()

Dim sheet_count As Integer
Dim sheet_name, new_sheet_name, old_str, new_str As String

sheet_count = ThisWorkbook.Sheets.Count
old_str = "A15"
new_str = "A02"

For i = 1 To sheet_count
sheet_name = Sheets(i).Name

'MsgBox InStr(sheet_name, old_str)

new_sheet_name = Replace(sheet_name, old_str, new_str)

MsgBox new_sheet_name

Sheets(i).Name = new_sheet_name

Next i

'MsgBox sheet_count

End Sub

原文地址:https://www.cnblogs.com/zerotomax/p/6675224.html