セルの書式を置換する際の、置換の基準を設定します。 その後、Range オブジェクトの Replace メソッドの呼び出しで、置換条件が使用されます。
構文
式。ReplaceFormat
expressionApplication オブジェクトを 表す変数。
例
次の例では、検索条件を設定して、Arial、Regular、Size 10 フォントを含むセルを検索し、それらの書式を Arial、Bold、Size 8 フォントに置き換えてから、SearchFormat と ReplaceFormat のオプション引数を True に設定して Replace メソッドを呼び出して、実際に変更を行います。
Sub MakeBold()
' Establish search criteria.
With Application.FindFormat.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
End With
' Establish replacement criteria.
With Application.ReplaceFormat.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 8
End With
' Notify user.
With Application.ReplaceFormat.Font
MsgBox .Name & "-" & .FontStyle & "-" & .Size & _
" font is what the search criteria will replace cell formats with."
End With
' Make the replacements on the worksheet.
Cells.Replace What:="", Replacement:="", _
SearchFormat:=True, ReplaceFormat:=True
End Sub
サポートとフィードバック
Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。