[VBA] How to Use “Shift + Ctrl + Down” and “Shift + Ctrl + Right”

目次

Environment

  • Windows Specification: Windows 10 Pro
  • Version: 20H2

Background

I wanted to use Excel’s shortcuts “Shift + Ctrl + Down” and “Shift + Ctrl + Right” in VBA, so I studied how to implement them.

How to Write the Code

You can write them as Selection, Selection.End(xlDown) and Selection, Selection.End(xlToRight).

First, here is the code:

Range("A3").Select

Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select

Explanation

(Blank lines are omitted in the count)

  • Line 1: Selects cell “A3”.
  • Line 2: This is the command for “Shift + Ctrl + Down”.
  • Line 3: This is the command for “Shift + Ctrl + Right”.

This allows you to select ranges using keyboard shortcuts via VBA.

Usage Example

I use this process when copying or deleting tables.

よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!

この記事を書いた人

私が勉強したこと、実践したこと、してることを書いているブログです。
主に資産運用について書いていたのですが、
最近はプログラミングに興味があるので、今はそればっかりです。

目次