共用方式為


(Excel) 的 Application.ReplaceFormat 屬性

設定取代準則用以取代儲存格格式。 接著會在後續呼叫Range物件的Replace方法時使用取代準則。

語法

運算式ReplaceFormat

expression 代表 Application 物件的變數。

範例

下列範例會設定搜尋準則來尋找包含 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 支援與意見反應