Range, cells, offset, and end of VBA

Source: Internet
Author: User
Differences between range, cells, offset, and end in VBA

I. Range attributes

1. select a single cell (for example, A5)

Range ("A5"). Select

2. Select a cell area (for example, A6: A10)

Range ("A6: A10"). Select

3. Select some non-adjacent cells (such as A1, B6, C8)

Range ("A1, B6, C8"). Select

4. select non-adjacent cells and cell areas (for example, A11: D11, B7, C9)

Range ("A11: D11, B7, C9"). Select

Ii. Cells attributes

1. select a single cell (for example, A5)

Cells (5, 1). Select cells (5, a). Select

2. Select a cell area (for example, A6: A10)

Range (cells (6, 1), cells (10, 1). Select

3. Select all cells in the worksheet

Cells. Select

Iii. offset attributes

1. Select cells in one row and three columns on the right under cell A1.

Range ("A1"). offset (1, 3). Select

2. Select cells in the first two rows and the first column on the left of cell D15.

Range ("D15"). offset (-2,-1). Select

3. Select cells in the same column (the last row)

Activecell. offset (-1, 0). Select

4. reselect a region

Activecell. offset (2, 2). Resize (2, 4). Select

Iv. End attribute (move to cells with continuous content)

1. Select the last cell of any row

Activecell. End (xltoright). Select

2. Select the first cell of any row.

Activecell. End (xltoleft). Select

3. Select the last cell of any column

Activecell. End (xldown). Select

4. Select the first cell of any column

Activecell. End (xlup). Select

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.