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 3 years have passed since last update.

【エクセル】セル操作

Last updated at Posted at 2021-02-24

参照

単一指定

  Range("A1")
  Cells(2, 3)

範囲指定

  Range("A2:C4")
  Range(Cells(3, 4), Cells(5, 8))
  Range(Range("A2"), Cells(5, 8))

行全体指定

  Range("D:D")          'D列
  Range("E:E", "G:G")   'E~G列
  Columns("D")          'D列
  Columns("E:G")        'E~G列

列全体指定

  Range("5:5")          '5行目
  Range("6:6", "8:8")   '6~8行目
  Rows("5")             '5行目
  Rows("6:8")           '6~8行目

最大行・列

'''vb
Rows.Count '最大列数 : 1047586
Column.Count '最大行数 : 16384
'''

CellとRangeの違い

 Range : 範囲指定可能
 Cells : 範囲指定不可⇒単一指定しかできない。

選択

  Range("A1:C3").Activate ` Active : 範囲選択する
 Range("A5").Select       ` Select : カーソルを合わせる

挿入・削除

  Rows(行位置).Delete
  Rows(行位置).Insert
  Columns(列位置).Delete
  Columns(列位置).Insert

Rangeのプロパティ

Resize

 Rangeの選択範囲を変更する

  ' A1を起点として2行3列 (A1:C2)にサイズを変更する。
 Range("A1").Resize(2, 3).Select

Offset

  ' A1の起点を2行2列ずらし(A1:B2) -> (C3:D4)に変更する。
  Range("A1:B2").Offset(2, 2).Value = 10

RangeとFor Each文

・走査の順序はA1, A2...C2,C3である。 (→ ↓)

  Dim r As Range
  For Each r In Range("A1:C3")
    MsgBox (r.Value)
  Next
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?