Excel VBA でショートカットキーを作成する
こんにちは。
仕事の自動化にやりがいと達成感を感じるガッくんです。
この記事の目次
背景・目的
久しぶりに Excel VBA でマクロ組んでる時にショーカットキーを割り当てたくて、エクセル既存のショートカットキー以外で、実際に Ctrl + Q とかを押しながら使えそうなキーの組み合わせを調べました。
もちろん、他にも使えるキーの組み合わせはあると思いますが、せっかく総当たり的に調べたので、忘れない為にも記事にしておきます。
ショートカットキー
キー組み合わせの右側には Excel VBA で実行すると macro というサブルーチンもしくは関数にショートカットキーが割り当てられるソースコードを書いています。
キー組み合わせ
Ctrl + R Application.OnKey "^r", "macro"
Ctrl + Y Application.OnKey "^y", "macro"
Ctrl + D Application.OnKey "^d", "macro"
Ctrl + J Application.OnKey "^j", "macro"
Ctrl + M Application.OnKey "^m", "macro"
Ctrl + 6 Application.OnKey "^6", "macro"
Ctrl + 7 Application.OnKey "^7", "macro"
Ctrl + < Application.OnKey "^<", "macro"
Ctrl + > Application.OnKey "^>", "macro"
Alt + Q Application.OnKey "%q", "macro"
Alt + U Application.OnKey "%u", "macro"
Alt + S Application.OnKey "%s", "macro"
Alt + G Application.OnKey "%g", "macro"
Alt + J Application.OnKey "%j", "macro"
Alt + K Application.OnKey "%k", "macro"
Alt + L Application.OnKey "%l", "macro"
Alt + Z Application.OnKey "%z", "macro"
Alt + C Application.OnKey "%c", "macro"
Alt + B Application.OnKey "%b", "macro"
Ctrl + Shift + Q Application.OnKey "+^q", "macro"
Ctrl + Shift + E Application.OnKey "+^e", "macro"
Ctrl + Shift + R Application.OnKey "+^r", "macro"
Ctrl + Shift + T Application.OnKey "+^t", "macro"
Ctrl + Shift + Y Application.OnKey "+^y", "macro"
Ctrl + Shift + I Application.OnKey "+^i", "macro"
Ctrl + Shift + A Application.OnKey "+^a", "macro"
Ctrl + Shift + S Application.OnKey "+^s", "macro"
Ctrl + Shift + D Application.OnKey "+^d", "macro"
Ctrl + Shift + G Application.OnKey "+^g", "macro"
Ctrl + Shift + H Application.OnKey "+^h", "macro"
Ctrl + Shift + J Application.OnKey "+^j", "macro"
Ctrl + Shift + K Application.OnKey "+^k", "macro"
Ctrl + Shift + Z Application.OnKey "+^z", "macro"
Ctrl + Shift + X Application.OnKey "+^x", "macro"
Ctrl + Shift + C Application.OnKey "+^c", "macro"
Ctrl + Shift + V Application.OnKey "+^v", "macro"
Ctrl + Shift + B Application.OnKey "+^b", "macro"
Ctrl + Shift + N Application.OnKey "+^n", "macro"
Ctrl + Shift + M Application.OnKey "+^m", "macro"
コメント
基本的にアルファベットキーで使えるようにしました。
実は忘れた頃に Excel でマクロにショートカットキーを割り当てたくなるので毎回調べていました。
2度と同じ調べ物はしたくないものですね。
以上