0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

セルの1行と1列を同時選択して十字の選択状態にする方法

Last updated at Posted at 2020-09-28
'''
'''目標Sheetに以下のCodeを埋め
'''
Private Sub Worksheet_BeforeDoubleClick _
    (ByVal Target As Range, Cancel As Boolean)
    Call RCSelect(Target)
End Sub


'''
'''共通Moduleに以下のCodeを埋めておく
'''
' 有効範囲を定義
Public Const minCol = 1
Public Const maxCol = 41
Public Const minRow = 4
Public Const maxRow = 5000
' 機能 : アクティブセルの行と列を同時選択する
' 引数 : Target アクティブセルなどのRangeオブジェクト
' 戻値 : なし
Sub RCSelect(Target As Range)
    If Target.CountLarge = 1 Then '単一セル選択時のみイベント発生
        Application.EnableEvents = False
        Dim rng_RC As Range
        Set rng_RC = Union(Range(Cells(Target.Row, minCol), Cells(Target.Row, maxCol)), Range(Cells(minRow, Target.Column), Cells(maxRow, Target.Column)))
        rng_RC.Select
        Target.Activate
        SendKeys "{F2}", True'編集をすぐできるようにしたい場合、この行を使う
        Application.EnableEvents = True
    End If
End Sub

参考先:https://chicktackgo.com/excel-vba-rcselect/

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?