• ベストアンサー

マクロを使ってコメントを大量に挿入したい。Excel2002

都市名が北から並んでいる表があり、各都市名にカーソルを合わせると各都市に応じたコメントが表示されるようにしたいです。表示させたいコメントの種類が5種類あり、塗りつぶし効果でコメントの背景に画像を表示させたりと、1つのコメントを作るのにちょっと手間がかかります。 少しでも手早くと思い、マクロの記録で手順を5パターン登録して、マクロの実行でコメントを表示させたいと考えております。でサンプルをひとつ作成し実行したのですがエラーになってしまいます。 (1)End with以降のselection.shaperange.fill~以降が駄目みたいで「オブジェクトはこのプロパティーまたはメソッドをサポートしていません」とエラーメッセージが表示されます。何がいけないのでしょうか? (2)G62のセルにコメントを挿入したいときのサンプルなんですが、G62だけじゃなくてどこのセルにでも対応できるようにしたいんですがどう書き直せば良いのでしょうか? 800字以内との規制があるみたいで関係ないと思われるエラー以降の部分を削除させて頂きました。何卒宜しくお願いいたします。 Sub Macro1() ' Macro1 Macro ' Range("G62").AddComment Range("G62").Comment.Visible = False Range("G62").Comment.Text Text:="" With Selection.Font .Name = "MS Pゴシック" .FontStyle = "太字" .Size = 9 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic End With Selection.ShapeRange.Fill.Transparency = 0# Selection.ShapeRange.Line.Weight = 0.75 Selection.ShapeRange.Line.DashStyle =     中略  End Sub

質問者が選んだベストアンサー

  • ベストアンサー
回答No.4

#2 misatoanna です。 > コードの6行目の "C:\MyFiles\Photos\Cats.jpg" この " " 内に、塗りつぶし効果で使う画像ファイルの実際のフルパスを書き込め ば表示されるはずなのですが。 次は、必要ないでしょうが、ついでです。 2枚目のシートの指定にもとづいて、1枚目のシートの各セルにコメントを挿入 する処理です。 2枚目のシートには、     A     B     C   1 \My Documents\GraphicData\Pic   2 B6  秘密!     Photo004.jpg   3 F2  大きすぎ    Masao_2.jpg   4 C12  メチャクチャ  Xmas2004.jpg   5 のように、2行目以降のA列にコメントを挿入するセル番地、B列にコメント文、 C列には背景に使用する画像ファイルのフルパスが入力されているとします。 セルA1は、画像ファイルが格納されているフォルダのフルパスです。 ' Sub CrtCmmt()   Dim i, myPath, myCL   Sheets(1).Select   myPath = Sheets(2).Range("A1").Value & "\" Pfm:   i = i + 1   myCL = Sheets(2).Cells(i + 1, 1).Value   If myCL = "" Then Exit Sub   Range(myCL).Select   Selection.AddComment   Selection.Comment.Visible = True   Selection.Comment.Text Text:=Sheets(2).Cells(i + 1, 2).Value   Selection.Comment.Shape.Select True   Selection.ShapeRange.Fill.UserPicture myPath & Sheets(2).Cells(i + 1, 3).Value   ActiveCell.Comment.Visible = False   GoTo Pfm End Sub

12tadashi
質問者

お礼

本当にありがとうございます。 最初にご回答頂いたものでもちゃんと画像が背景に挿入されました。フルパスの前のアンダーバーが抜けておりました。 今回のものはさらに便利で、画像もコメントの中に入れる文章も簡単に表示させることができました。 これで大丈夫です。 重ねてのご回答、本当にありがとうございます。

その他の回答 (3)

  • Wendy02
  • ベストアンサー率57% (3570/6232)
回答No.3

こんにちは。 私も考えてみました。 >表示させたいコメントの種類が5種類あり、塗りつぶし効果でコメントの背景に画像を表示させたりと、1つのコメントを作るのにちょっと手間がかかります。 コメントが5種類あるとしたら、以下のように(,)コンマ区切りにして、総合コメントに書いておきます。 以下は、ActiveCell に入れられるようになっていますが、UserFormのモードレスモードなどのほうが、セルを自由に選べて便利です。Application.Input でも出来ないことはありませんが、勝手が悪いのです。 後は工夫してください。 Const myComment As String = "本日は晴天なり,本日は、曇天なり,本日は、雨天なり,本日は、風強し" Sub CellCommentIn()  Dim ret As Variant, i As Long  Dim msg As String, myComments As Variant  myComments = Split(myComment, ",")  For i = LBound(myComments) To UBound(myComments)   msg = msg & i + 1 & "." & myComments(i) & vbCr  Next  ret = Application.InputBox(msg & "コメントの数字を選んでください", Type:=2)  If VarType(ret) = vbBoolean Or ret = "" Then Exit Sub  With ActiveCell   'もし、コメントがあれば最初に削除する   If Not .Comment Is Nothing Then    .Comment.Delete   End If   .AddComment   .Comment.Visible = False   .Comment.Text Text:=myComments(ret - 1)   With .Comment.Shape      'ここは、特別な設定しなければ、要らないかもしれない    With .TextFrame.Characters.Font     .Name = "MS Pゴシック"     .FontStyle = "太字"     .Size = 9     .ColorIndex = xlAutomatic    End With    .Fill.Transparency = 0#    .Line.Weight = 0.75   '中略   End With  End With End Sub

12tadashi
質問者

お礼

早速のご回答にもかかわらず、色々と試行させて頂いておりまして、御礼が遅くなり失礼致しました。 内容は完璧で、とても簡単に数種類のコメントを挿入することができました。こんな風にコメントが選択できる方法があるんですね。とっても勉強になりました。 Wendy02さんには以前にも違う質問でご教授頂いておりまして、本当にありがとうございます。 お忙しいところのご回答に心より感謝申し上げます。

回答No.2

選択されているセル(ひとつ)にコメントと背景画をセットする簡単な例です。 複数セルへの自動挿入ルーティン部分は省略しています。 エラーは、背景画を塗りつぶすときにコメントが表示されていないからだと 思いますので、※印の行のように指定すればよいでしょう。 Sub CrtCmmt()   Selection.AddComment   Selection.Comment.Visible = True    '※   Selection.Comment.Text Text:="これはテストです。"   Selection.Comment.Shape.Select True  '※   Selection.ShapeRange.Fill.UserPicture "C:\MyFiles\Photos\Cats.jpg"   ActiveCell.Comment.Visible = False   '※ End Sub

12tadashi
質問者

お礼

いろいろと試させて頂きました。とっても便利で活用させて頂きたいと思います。 とても初歩的な事で失礼かもしれないんですが、 書いていただいたコードの6行目の "C:\MyFiles\Photos\Cats.jpg" の部分を指定の画像に書き換えればよいんですよね? 何度やっても画像がコメントの背景に設定されないんですが、単純に書き換えても駄目なんでしょうか? 重ねての質問、大変恐縮なんですが、お手すきの時で構いませんので宜しくお願い致します。

  • merlionXX
  • ベストアンサー率48% (1930/4007)
回答No.1

B1からB10セルにコメントを挿入し、コメントの文字は同じ行のF列から持ってくるマクロです。ご参考まで。 Sub TEST01() For i = 1 To 10 With Cells(i, 2) .AddComment .Comment.Visible = False .Comment.Text Text:=Cells(i, 6).Text End With Next End Sub

12tadashi
質問者

お礼

試してみました。こんな簡単にコメントを入れる方法があるんですね。凄いです。 勉強になりました。ありがとうございます。

関連するQ&A

  • Excel-VBA コメントの書式設定

    Excel-VBA コメントの書式設定 コメントの書式設定をExcel-VBAで定義したい。 従い「マクロの記録」を実行して下記のソースコードを取得しました。 これを実行すると次の実行エラーが発生しました!? ★正常に動作させるソースコードの事例をいただければ幸いです。 ご指導よろしくお願いいたします。 実行時エラー'438' オブジェクトは、このプロパティまたはメソッドをサポートしていません。 Sub Macro1() ' 処理:マクロの記録 ' 目的:「コメントの挿入」と「コメントの書式設定」をする。 Range("A2").Select Range("A2").AddComment Range("A2").Comment.Visible = False Range("A2").Comment.Text Text:="コメント" & Chr(10) & "今日は良いお天気ですね。" '▽次で実行エラーが起きる!? Selection.ShapeRange.ScaleWidth 1.58, msoFalse, msoScaleFromTopLeft Selection.ShapeRange.ScaleHeight 1.49, msoFalse, msoScaleFromTopLeft Selection.ShapeRange.Fill.Visible = msoTrue Selection.ShapeRange.Fill.Solid Selection.ShapeRange.Fill.ForeColor.SchemeColor = 9 Selection.ShapeRange.Fill.Transparency = 0# Selection.ShapeRange.Line.Weight = 0.75 Selection.ShapeRange.Line.DashStyle = msoLineSolid Selection.ShapeRange.Line.Style = msoLineSingle Selection.ShapeRange.Line.Transparency = 0# Selection.ShapeRange.Line.Visible = msoTrue Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 0) Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255) Selection.ShapeRange.LockAspectRatio = msoTrue Selection.ShapeRange.Height = 141.75 Selection.ShapeRange.Width = 283.5 Range("A1").Select End Sub

  • エクセル。マクロの記録で出来たVBAを書き直したい。

    エクセル2000(OSはWindows2000)でマクロの記録を行いました。 四角形を出してA1セルにリンクさせフォント等の設定をしたものです。 Sub Macro5() ActiveSheet.Shapes.AddShape(msoShapeRectangle, 200#, 100#, 140#, 80#). _ Select ExecuteExcel4Macro "FORMULA(""=R1C1"")" With Selection.Font .Name = "Century Gothic" .FontStyle = "太字" .Size = 72 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic End With Selection.ShapeRange.Fill.Visible = msoFalse Selection.ShapeRange.Fill.Transparency = 0# Selection.ShapeRange.Line.Weight = 0.75 Selection.ShapeRange.Line.DashStyle = msoLineSolid Selection.ShapeRange.Line.Style = msoLineSingle Selection.ShapeRange.Line.Transparency = 0# Selection.ShapeRange.Line.Visible = msoFalse End Sub これを、実際には四角形をセレクトしないで実行させたいのです。 With ActiveSheet.Shapes.AddShape~ End With といった形になるのでしょうが、どうもうまく出来ません。 ご教示いただければ幸いです。

  • Excel マクロ 任意のセルから実行したい

    こんにちは、Excel2003を使用しています。 ExcelでK55からE55までのセルの値を削除して(空白にして) それぞれに「---を引いた透明のダイアローグボックス」を コピーしていくマクロを作成したことがあります。 このときは開始するセルがK55と決まっていたのですが 今度は任意のセルから(たとえば選択したセルの右隣とか) 実行したいのですがどのようにマクロを作ればよいでしょうか ご存じの方お教えください。 なお参考に上記のマクロを記載します。 Range("E55:J55").Select Selection.ClearContents Range("H55").Select ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, 672#, 729#, _ 81#, 13.5).Select Selection.Characters.Text = "" With Selection.Font .Name = "MS Pゴシック" .FontStyle = "標準" .Size = 11 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic End With Selection.ShapeRange.Fill.Visible = msoFalse 'Selection.ShapeRange.Fill.Solid 'Selection.ShapeRange.Fill.Transparency = 0# Selection.ShapeRange.Line.Weight = 0.75 Selection.ShapeRange.Line.DashStyle = msoLineSolid Selection.ShapeRange.Line.Style = msoLineSingle Selection.ShapeRange.Line.Transparency = 0# Selection.ShapeRange.Line.Visible = msoFalse ActiveSheet.Shapes("Text Box 12").Select Selection.Characters.Text = "---" With Selection.Characters(Start:=1, Length:=3).Font .Name = "MS Pゴシック" .FontStyle = "標準" .Size = 11 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic End With Selection.HorizontalAlignment = xlCenter Range("K55").Select ActiveSheet.Shapes("Text Box 12").Select Selection.Copy Range("I55").Select ActiveSheet.Paste Range("H55").Select ActiveSheet.Paste Range("G55").Select ActiveSheet.Paste Range("F55").Select ActiveSheet.Paste Range("E55").Select ActiveSheet.Paste Range("E56").Select Selection.Copy Range("F56:J56").Select ActiveSheet.Paste Application.CutCopyMode = False Range("E56:J56").Select Selection.Copy Range("E57:E59").Select ActiveSheet.Paste Application.CutCopyMode = False Range("K59").Select End Sub

  • エクセルVBAのWith~End With構文

    Win2000エクセル2000です。 下記のMacro11はTEST11のようにWith~End Withでくくれると思うのですがエラーになります。 どこがおかしいのでしょうか? Sub Macro11() ActiveSheet.Shapes.AddShape(msoShapeSun, 450, 150, 120, 120).Select Selection.ShapeRange.Line.Weight = 0.75 Selection.ShapeRange.Line.ForeColor.SchemeColor = 64 Selection.ShapeRange.Fill.ForeColor.SchemeColor = 10 Selection.ShapeRange.Fill.OneColorGradient msoGradientFromCorner, 1, 0.59 Selection.ShapeRange.Adjustments.Item(1) = 0.3016 Selection.ShapeRange.ThreeD.SetThreeDFormat msoThreeD7 Selection.ShapeRange.ThreeD.PresetMaterial = msoMaterialMetal Selection.ShapeRange.ThreeD.Depth = 144# End Sub Sub TEST11() With ActiveSheet.Shapes.AddShape(msoShapeSun, 450, 150, 120, 120) .ShapeRange.Line.Weight = 0.75 .ShapeRange.Line.ForeColor.SchemeColor = 64 .ShapeRange.Fill.ForeColor.SchemeColor = 10 .ShapeRange.Fill.OneColorGradient msoGradientFromCorner, 1, 0.59 .ShapeRange.Adjustments.Item(1) = 0.3016 .ShapeRange.ThreeD.SetThreeDFormat msoThreeD7 .ShapeRange.ThreeD.PresetMaterial = msoMaterialMetal .ShapeRange.ThreeD.Depth = 144# End With End Sub

  • マクロを使ってexcel2007でテキストボックス内をセンタリングしたい

    以前、excel2000でマクロの児童記録で記録し、それを利用して 下のようなマクロを使っていました (列ボックス1は変数) ActiveSheet.Shapes.AddTextbox(msoTextOrientationVerticalFarEast, 列ボックス1, 205 , 15, 105).Select Selection.Characters.Text = 顧客名 With Selection.Characters.Font .Name = "MS Pゴシック" .FontStyle = "標準" .Size = 8 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = 3 End With With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlTop .Orientation = xlVertical .AutoSize = False .AddIndent = False End With Selection.ShapeRange.Fill.Visible = False Selection.ShapeRange.Fill.Solid Selection.ShapeRange.Fill.Transparency = 1# Selection.ShapeRange.Line.Weight = 0.75 Selection.ShapeRange.Line.DashStyle = msoLineSolid Selection.ShapeRange.Line.Style = msoLineSingle Selection.ShapeRange.Line.Transparency = 0# Selection.ShapeRange.Line.Visible = msoFalse Selection.ShapeRange.TextFrame.MarginLeft = 0 Selection.ShapeRange.TextFrame.MarginRight = 0 Selection.ShapeRange.TextFrame.MarginTop = 0 Selection.ShapeRange.TextFrame.MarginBottom = 0 これで問題なく動作していたのですが excel2007で動作させると テキストボックス内が水平方向にセンタリングされていません。 excel2007でテキストボックスをかく記録をしてもマクロには何も残らず 困っています。 excel2007でも、センタリングさせる方法を教えて下さい どうかよろしくお願いします

  • Excel2007 VBAで画像挿入について

    Sub 図形挿入等倍() Dim FilePath As Variant FilePath = Application.GetOpenFilename(",*.png") If Not FilePath = False Then ActiveSheet.Pictures.Insert(FilePath).Select Selection.ShapeRange.LockAspectRatio = msoTrue Selection.ShapeRange.Width = Selection.ShapeRange.Width * 1# Selection.ShapeRange.Left = ActiveCell.Left + 2.25 Selection.ShapeRange.Top = ActiveCell.Top + 2.25 End If With Selection.ShapeRange.Line .Weight = 2.25 '線の太さを2.25に .ForeColor.RGB = RGB(255, 0, 0) '赤枠に End With End Sub 上記のコードを書き、画像を挿入したときは問題ないのですが 画像を挿入せずにキャンセルすると 実行時エラー438 オブジェクトは、このプロパティまたはメソッドをサポートしていません。とでてしまいます デバックをしてみると With Selection.ShapeRange.Lineの部分が黄色くなっているので ここを修正したらいいと思うのですが どのように修正したらいいのか分かりません お分かりの方いましたらご教授お願い致します

  • Excel2003枠を作るマクロ

    右側に空白の行を一つつくって枠を作りたいです。 たとえば、G100が一番右下とするとH100まで枠を作りたいのですが、きれいにかくにはどうしたらよいでしょうか? マクロ記録でやると、下のようになるのですが右下が100で有るとは限らないのでその行を定義する必要があると思うのですが、そのあたりがさっぱりわかりません。 よろしくお願いいたします。 Sub Macro1() Selection.End(xlDown).Select Range("H100").Select Range(Selection, Selection.End(xlUp)).Select Range(Selection, Selection.End(xlToLeft)).Select Range(Selection, Selection.End(xlToLeft)).Select Range(Selection, Selection.End(xlToLeft)).Select Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlInsideVertical) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlInsideHorizontal) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With End Sub

  • Excel 任意のセルを指定する方法

    Excel 任意のセルを指定する方法 こんにちは Excel2003でセルの上を「---」で覆うマクロを作成しました。(以下参照) でもこれはセル「K2」に作成されます。 任意の作成したいセルを「---」で覆うようにするのには どのように改造すればよいでしょうか? おわかりの方お教えください。 ' 透明なセルを一つ作るマクロ ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, 672.75, 13.5, _ 81#, 13.5).Select Selection.Characters.Text = "---" With Selection.Characters(Start:=1, Length:=3).Font .Name = "MS Pゴシック" .FontStyle = "標準" .Size = 11 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic End With Selection.HorizontalAlignment = xlCenter Selection.ShapeRange.Fill.Visible = msoFalse 'Selection.ShapeRange.Fill.Solid 'Selection.ShapeRange.Fill.Transparency = 0# Selection.ShapeRange.Line.Weight = 0.75 Selection.ShapeRange.Line.DashStyle = msoLineSolid Selection.ShapeRange.Line.Style = msoLineSingle Selection.ShapeRange.Line.Visible = msoFalse Range("K2").Select End Sub

  • 【自作マクロ】いらない部分を削除していただきたい。

    自分で行ってみたマクロですが、長く、見づらいです。 いらない部分を削除していただける方がいましたら、お願いいたします。 作業としては、 /////////////////////////////////// あああ いいい ううう えええ おおお かかか      あかさたなはまやらわん の、「あかさたなはまやらわん」を削除し、セルの結合を解除し、 あああ、いいい など文字のあるセルと下のセルを結合して格子をつける。 /////////////////////////////////// Sub 項目を1行にして摘要を削除する() ' ' 項目を1行にして摘要を削除する Macro ' ' Range("C7:H7").Select ActiveCell.FormulaR1C1 = "" Range("C7:H7").Select With Selection .HorizontalAlignment = xlGeneral .VerticalAlignment = xlCenter .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = True End With Selection.UnMerge Range("C6:C7").Select With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With Selection.Merge Range("D6:D7").Select With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With Selection.Merge Range("E6:E7").Select With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With Selection.Merge Range("F6:F7").Select With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With Selection.Merge Range("G6:G7").Select With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With Selection.Merge Range("H6:H7").Select With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With Selection.Merge Range("C6:H7").Select Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlThin End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlThin End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlThin End With With Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlThin End With With Selection.Borders(xlInsideVertical) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlThin End With With Selection.Borders(xlInsideHorizontal) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlThin End With End Sub

  • 任意のセルでマクロを実行させたい

    アクティブセルにマクロを実行させたいのですがうまくいきません。 2007のエクセルを使用しています。 (1)命令文で指定しているセル(G9:G11)をJ9:J11やR14:R16等でも使用したい。 (2)また作成したマクロを同シート内オートシェイプに登録したい。 よろしくお願いいたします。 Sub Macro2() ' ' Macro2 Macro ' ' Range("G9:G11").Select Selection.ClearContents With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlTop .Orientation = xlVertical .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = True End With With Selection.Font .Name = "MS P明朝" .FontStyle = "標準" .Size = 11 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic .TintAndShade = 0 .ThemeFont = xlThemeFontNone End With With Selection.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .Color = 16777164 .TintAndShade = 0 .PatternTintAndShade = 0 End With ActiveCell.FormulaR1C1 = "搬入" With ActiveCell.Characters(Start:=1, Length:=2).Font .Name = "MS P明朝" .FontStyle = "標準" .Size = 11 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic .TintAndShade = 0 .ThemeFont = xlThemeFontNone End With ActiveCell.Characters(1, 2).PhoneticCharacters = "ハンニュウ" Range("G12").Select End Sub

専門家に質問してみよう