Application.ReplaceFormat プロパティ (Excel)

セルの書式を置換する際の、置換の基準を設定します。 その後、置換条件は、Range オブジェクトの Replace メソッドの後続の呼び出しで使用されます。

構文

ReplaceFormat

expressionApplication オブジェクトを 表す変数。

次の使用例は、Arial、Regular、Size 10 フォントを含むセルを検索する検索条件を設定し、その書式を Arial、Bold、Size 8 フォントに置き換え、 Replace メソッドを呼び出し、 SearchFormatReplaceFormat の省略可能な引数を True に設定して、実際に変更を行います。

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 のサポートおよびフィードバックを参照してください。