一括置換
2012年07月14日
【VBA】(ブック全体)一括置換
Private Sub CommandButton11_Click()
Dim sSrc As Variant
Dim sRep As Variant
Dim wh As Worksheet
sSrc = Application.InputBox("検索値を入力してください。", "検索値", Type:=2)
If VarType(sSrc) = vbBoolean Or sSrc = "" Then Exit Sub
sRep = Application.InputBox("置換を入力してください。", "置換値", Type:=2)
If VarType(sRep) = vbBoolean Or sRep = "" Then Exit Sub
For Each wh In ActiveWorkbook.Worksheets
wh.UsedRange.Replace _
What:=sSrc, _
Replacement:=sRep, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False
Next wh
End Sub
続きを読む