How Excel uses the copy command in VBA

Source: Internet
Author: User

1, first we open a work sample table as an example.

2, the Copy method is the Excel worksheet Copy command, use the mouse to select cells or range cells, and then select the Copy command in the mouse mail panel, or use the CTRL + C key combination.

3, we use the ALT+F11 combination shortcut key into the VBE editor, insert a new module, and enter the following code in the module:

Option Explicit

Sub Cy ()

Sheets (1). Range ("A1"). Copy

End Sub

4, here first to enter the object sheet, specify a correct worksheet. Sheets (1) is the May payroll form, and the Range property is exactly the cell or range of cells selected by the mouse.

5. Here we have a copy method for the A1 cell of the May wage-object worksheet, which is to save the cell's data in memory. is equivalent to the commands in Excel. If you need to paste, you need to specify the cell object and use the Pastaspecial method to paste it.

6, of course, the use of paste method, very accurate, but also caused a part of the use of inconvenience, because the paste method requires a variety of parameters. If you just copy the value, then we can simply use a simple method to enter the target cell or range directly as a copy parameter. For example sheets (1). Range ("B7"). Copy Sheets (1). Range ("B20")

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.