| 
    
     |  | Asaki さん、Macroの記録でやってみたのですが・・ 
 まず、Sheet2のM列にある「りんご」を検索させて、
 Sheet1のA2に入力されている「りんご」の書式に
 変更させる操作をしました。
 
 以下の通りです。
 
 
 Sub Macro7()
 '
 
 '
 Sheets("Sheet2").Select
 Columns("M:M").Select
 Sheets("Sheet1").Select
 Range("A2").Select
 Application.ReplaceFormat.Clear
 Application.ReplaceFormat.NumberFormat = "G/標準"
 With Application.ReplaceFormat
 .HorizontalAlignment = xlCenter
 .VerticalAlignment = xlCenter
 .WrapText = False
 .Orientation = 0
 .AddIndent = False
 .ShrinkToFit = False
 End With
 With Application.ReplaceFormat.Font
 .Name = "MS Pゴシック"
 .FontStyle = "太字"
 .Size = 11
 .Strikethrough = False
 .Superscript = False
 .Subscript = False
 .ColorIndex = 3
 End With
 Application.ReplaceFormat.Borders(xlLeft).LineStyle = xlNone
 Application.ReplaceFormat.Borders(xlRight).LineStyle = xlNone
 Application.ReplaceFormat.Borders(xlTop).LineStyle = xlNone
 Application.ReplaceFormat.Borders(xlBottom).LineStyle = xlNone
 Application.ReplaceFormat.Borders(xlDiagonalDown).LineStyle = xlNone
 Application.ReplaceFormat.Borders(xlDiagonalUp).LineStyle = xlNone
 Application.ReplaceFormat.Interior.ColorIndex = xlNone
 Application.ReplaceFormat.Locked = True
 Application.ReplaceFormat.FormulaHidden = False
 Sheets("Sheet2").Select
 Selection.Replace What:="りんご", Replacement:="", LookAt:=xlPart, _
 SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
 ReplaceFormat:=True
 End Sub
 
 ところが、このマクロを再度実行しようとしたら
 '実行時エラー 1004
 アプリケーション定義またはオブジェクト定義のエラーです。
 というメッセージが出てきます。
 
 何故でしょうか?
 
 
 |  |