将所选数据从一个工作簿复制到另一个工作簿

时间:2022-09-15 21:45:01

I'm a bit new here & also new with VB. I have 2 workbooks. In WB 1 some data are there. Now I need to copy those data to WB 2. But not all of them. In srcsht there are 9 columns. In destsht there are only 5. Plus based on column 4 in srcsht i.e. Region, i need to copy the data for only East & not the rest, which is there at destsht in column 2. Another thing is as i enter more rows in srcsht, the same should be increased in destsht too.

我在这里有点新,也是VB的新手。我有2本工作簿。在WB 1中有一些数据。现在我需要将这些数据复制到WB 2.但不是全部。在srcsht中有9列。在destsht中只有5.加上基于第4列的srcsht即Region,我需要复制仅用于East的数据而不是其余的数据,这是在第2列的destsht中。另一件事是我在srcsht中输入更多行同样也应该在destsht中增加。

1 个解决方案

#1


0  

Here an example

这是一个例子

Workbook("WB 1").Worksheets("worksheet1").Range("A2:B14").Copy _
Destination:=Workbooks("WB 2").Worksheets("worksheet1").Range("A1")

It selects the datas from the workbook named WB 1 which are in the worksheet1. You put the range you want. You .copy the datas selected and you do the same with the destination (where you want to past the datas copied)

它从工作表1中名为WB 1的工作簿中选择数据。你把你想要的范围。您.copy选择的数据,并对目的地(您要通过复制的数据)执行相同的操作

Just chose the datas you want to copy and the destination

只需选择要复制的数据和目的地

#1


0  

Here an example

这是一个例子

Workbook("WB 1").Worksheets("worksheet1").Range("A2:B14").Copy _
Destination:=Workbooks("WB 2").Worksheets("worksheet1").Range("A1")

It selects the datas from the workbook named WB 1 which are in the worksheet1. You put the range you want. You .copy the datas selected and you do the same with the destination (where you want to past the datas copied)

它从工作表1中名为WB 1的工作簿中选择数据。你把你想要的范围。您.copy选择的数据,并对目的地(您要通过复制的数据)执行相同的操作

Just chose the datas you want to copy and the destination

只需选择要复制的数据和目的地