Excel VBA すべてのシートに対して一括置換
ナビゲーションに移動
検索に移動
Excel VBA すべてのシートに対して一括置換
すべてのシートに対して一括置換する
Sub AllReplace()
Dim f As String
Dim t As String
Dim i As Integer
Dim sht As Excel.Worksheet
f = InputBox("置換対象文字列を入力してください")
If Trim$(f) <> "" Then
t = InputBox("置換後文字列を入力してください")
End If
If Trim$(t) = "" Then
Exit Sub
End If
For i = 1 To ActiveWorkbook.Sheets.Count
Set sht = ActiveWorkbook.Sheets(i)
If sht.Name = f Then
sht.Name = t
End If
sht.Cells.Replace What:=f, Replacement:=t, LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, MatchByte:=False
Next
Call MsgBox("完了")
End Sub
© 2006 矢木浩人