どのコマンドバーボタンをVBAを使用してマクロを起動するかを決定する方法?


この記事では、どのコマンドバーボタンがマイクロソフトExcelでVBA * *を使用してマクロを起動するかを決定する方法を学びます.下で見ましょう!次のリンクからMS Excelの公式バージョンを取得します.https://www.microsoft.com/en-in/microsoft-365/excel

  • まず、Excelのワークシートでは、[開発]タブに移動する必要があります.
  • 次に、コードセクションの下のVisual Basicオプションを選択する必要があります.
  • 選択します
  • さて、以下のコードをコピーしてペーストしなければなりません.
  • Sub DummyMacro()
        If Application.CommandBars.ActionControl Is Nothing Then 
        ' the macro was not started from a commandbar button
            MsgBox "This could be your macro running!", vbInformation, _
                "This macro was not started from a CommandBar button"
        Else ' the macro was started from a commandbar button
            MsgBox "This could be your macro running!", vbInformation, _
                "This macro was started from this CommandBar button: " & _ 
                Application.CommandBars.ActionControl.Caption
        End If
    End Sub
    
    
  • 選択してコードを保存し、ウィンドウを閉じる必要があります.
  • コードを保存する
  • 再度、Excelのスプレッドシートに移動し、[開発]タブをクリックします.
  • 次に、コードセクションでマクロオプションを選択する必要があります.
  • マクロオプションの選択
  • ここで、マクロ名が選択されていることを確認し、* Run *ボタンをクリックします.
  • コードを実行する
  • 最後にマクロを実行した後、Excelで以下のように*出力*を取得します.
  • 出力

    包む
    この記事では、どのコマンドバーボタンをマイクロソフトExcelでVBAを使用してマクロを起動するかを決定する方法についてのガイドラインを示します任意のクエリの場合にコメントを残して、同様にあなたの貴重な提案を言及することを忘れないでください.私たちのサイトを訪問していただきありがとうございます!学習を続けるGeek Excel !! *続きを読むExcel Formulas *!!
    関連記事
  • Excel Formulas to Find Pass or Fail Using COUNTIF Function!!
  • Insert Multiple Option Buttons at Once in Excel Office 365!!
  • Batch Delete Option Buttons with One Click in Excel Office 365!!
  • How to use DATE Function in Microsoft Excel 365?