[英]Excel VBA Workbook_open event handler required
I have reference data in columns A and B on Sheet2 of my WorkBook
. 我在WorkBook
Sheet2上的A和B列中有WorkBook
。 I have a blank sheet - Sheet1 - which i need to fill from my database. 我有一张白纸 - Sheet1 - 我需要从我的数据库中填写。
I want to use Excel VBA to fill Sheet1 based on data in columns A and B in Sheet2 . 我想使用Excel VBA根据Sheet2中 A列和B列中的数据填充Sheet1 。
I use the reference data by. 我使用参考数据。
ThisWorkbook
, right click it, and select View Code . 在工作表列表的底部是一个名为ThisWorkbook
的对象,右键单击它,然后选择查看代码 。 Workbook
from the list. 在顶部应该看到两个组合框,右手应该说一般点击它并从列表中选择Workbook
。 This should give you the following 这应该给你以下
Private Sub Workbook_Open()
End Sub
This is the event that is fired each time the work book is opened. 这是每次打开工作簿时触发的事件。 Now you will need to add code to reference the sheets in the workbook. 现在,您需要添加代码以引用工作簿中的工作表。
Here is some methods for how to reference sheets in vba Reference sheets . 以下是有关如何在vba 参考表中引用工作表的一些方法。 Next step will be to refer to the cells in the sheets see - > excel ranges as an example. 下一步将参考工作表中的单元格,参见 - > excel范围作为示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.