「Excel VBA すべてのシートに対して一括置換」の版間の差分
ナビゲーションに移動
検索に移動
| 1行目: | 1行目: | ||
==Excel VBA すべてのシートに対して一括置換== | ==Excel VBA すべてのシートに対して一括置換== | ||
| − | [[Excel][Excel VBA]] | + | [[Excel]][[Excel VBA]] |
{{amazon|4798122084}} | {{amazon|4798122084}} | ||
2020年2月15日 (土) 08:19時点における版
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 矢木浩人