vba 在 Excel 中的工作簿之间自动传输数据

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20424051/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 00:50:28  来源:igfitidea点击:

Automate data transfer between workbooks in Excel

excelvba

提问by user3074433

I admit to not being very technical and my limit up to now has been using paste links to connect data between sheets. I now have a requirement I cannot figure out.

我承认技术水平不高,到目前为止我的限制一直是使用粘贴链接来连接工作表之间的数据。我现在有一个我无法弄清楚的要求。

I have 2 workbooks I wish to automate sharing data between.

我有 2 个工作簿,我希望在它们之间自动共享数据。

Workbook 1 contains multiple rows of data manually entered.

工作簿 1 包含手动输入的多行数据。

I need a button against each row so when it is pressed data from certain cells on that row in Workbook 1 are transferred to cells within a worksheet in workbook 2

我需要对每一行都有一个按钮,因此当它被按下时,来自工作簿 1 中该行的某些单元格的数据将传输到工作簿 2 中工作表中的单元格

I would be very grateful for any guidance on how to achieve this.

我将非常感谢有关如何实现这一目标的任何指导。

Many thanks!

非常感谢!

回答by Youbaraj Sharma

Though you can deploy VBA to achieve this, but the same is also possible with simple formula like.

虽然您可以部署 VBA 来实现这一点,但同样也可以使用简单的公式来实现。

   =[1.xlsx]Sheet1!$A

Lets say you have two workbooks 1.xlsx and 2.xlsxand you want sheet1/column A1value from 1.xlsxto be auto populated in sheet1/column A1in 2.xlsx, you can simply link it with a formula like =[1.xlsx]Sheet1!$A$1in second workbook 2.xlsx.

假设您有两个工作簿,1.xlsx and 2.xlsx并且希望将sheet1/column A1from 的值1.xlsx自动填充到sheet1/column A1in 中2.xlsx,您可以简单地将其与=[1.xlsx]Sheet1!$A$1第二个工作簿中的公式链接2.xlsx

So as soon as some entry is done in first cell, second cell is auto populated

因此,只要在第一个单元格中完成某些条目,就会自动填充第二个单元格

However if you are looking only for vba solution do write back

但是,如果您只寻找 vba 解决方案,请回写