更新日:、 作成日:
VBA コードの行番号を表示する
はじめに
Excel VBA マクロでコードの行番号を表示する方法を紹介します。
行番号を表示すると、今どこのコードを編集しているのかわかりやすくなります。
行番号を表示する
標準で VBA のコードの行番号は表示できません。有志の方が作成したアドイン「AddLineNumbers」で行番号を表示する方法を紹介します。
次のページを開き [Download addlinenumbers141.zip] をクリックします。

ダウンロードしたファイルを解凍します。

アドインをレジストリに登録後はファイルを移動できなくなるので、問題ない場所にフォルダを移動します。
検索ボックスに コマンドプロンプト と検索します。[コマンドプロンプト] を右クリックして [管理者として実行] をクリックします。

64 ビットの Windows で 32 ビットの Office を使用しているときは cd %SystemRoot%\SysWOW64 を入力して Enter キーを入力します。後は 32 ビットと 64 ビットで共通です。

フォルダの中の [VB6IDEAddLineNumbersAddin.dll] を Shift キーを押しながら右クリックして [パスのコピー] をクリックします。

regsvr32 を入力し、右クリックして貼り付けます。

regsvr32 "パス\VB6IDEAddLineNumbersAddin.dll" のようになっていたら Enter キーを入力します。

[OK] をクリックします。

これでコードの行番号が表示されます。

スポンサーリンク
行番号を非表示にする
[アドイン] から [アドイン マネージャー] をクリックします。

[AddLineNumBers] を選択し、[ロード/アンロード] と [起動時にロード] のチェックを外して [OK] をクリックします。

行番号が非表示になります。

アンインストール
アドインをレジストリから解除してファイルを削除するには、インストールする手順と同じ方法でコマンドプロンプトを表示します。
64 ビットの Windows で 32 ビットの Office を使用しているときは cd %SystemRoot%\SysWOW64 を入力して Enter キーを入力します。後は 32 ビットと 64 ビットで共通です。

regsvr32 /u を入力し、右クリックしてアドインのパスを貼り付けます。

regsvr32 /u "パス\VB6IDEAddLineNumbersAddin.dll" のようになっていたら Enter キーを入力します。

[OK] をクリックします。

アドインのファイルを削除します。
スポンサーリンク