- 追加された行はこのように表示されます。
- 削除された行は
このように表示されます。
!!!Excel VBA すべてのシートに対して一括置換
[Excel][Excel VBA]
{{amazon 4798122084}}
!すべてのシートに対して一括置換する
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