Current location - Loan Platform Complete Network - Big data management - In excel vba, I want to copy the contents of one area to another table, but the number of columns in the copied area is a variable. How to write a program?
In excel vba, I want to copy the contents of one area to another table, but the number of columns in the copied area is a variable. How to write a program?
Concise:

Mark I as an integer

i = 2

Range (cell (1, 1), cell (2, i)). Copy the paper (2). Scope ("a 1")

If you want to open the worksheet (2), please add the statement: worksheet (2). Finally activated.

You can also use the following statement:

Range ("a 1"). Adjust the size (2, i). Copy the paper (2). Scope ("a 1")

Description:

The Resize property of the Range object is used to resize the specified range and return the adjusted cell range.

Syntax: resizing (browsing, column sizing)

The RowSize parameter and the ColumnSize parameter represent the number of rows and columns in the adjusted cell area, respectively.