修改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

posted @ 2017-04-06 20:13  Ouka傅  阅读(301)  评论(0编辑  收藏  举报