VBA EXCEL update cell in another workbook without

2019-08-12 04:50发布

I have a directory with list of Workbooks, I want to loop through them withouth opening them and update a Cell in a certain Sheet

I have tried to use

Dim wb As Workbook
Set wb = Workbooks("Z:\dir\bla.xls") 'THIS WILL COME TRHOUGH WHEN I LOOP 
Set ws2 = wb.Sheets("TestSheet") 'SHEET NAME

Set CurCell_2 = ws2.Range("A1")
CurCell_2.Value = 5

The Problem comes it only works when I have the Workbook already open. I can use:

Workbooks.Open

But then It opens up in the background and takes to long to run through them all.

Can anyone help please

标签: excel vba
1条回答
家丑人穷心不美
2楼-- · 2019-08-12 05:15

You cannot do that without opening the workbooks. However, I have found in my case that using Application.EnableEvents and setting it to false sped up greatly the process because we have macros on workbook open event.

查看更多
登录 后发表回答