目次
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.
