一次运行多个工作簿Excel

时间:2019-07-30 08:06:04

标签: excel vba

我想知道是否有人运行过多个excel实例。背景是我有一个excel工作簿vba sub,它每月进行一次计算,需要60分钟。我创建了一个包装器,您给它指定了一个开始月份和几个月的时间,并贯穿其中保存了每个月工作簿。

问题是,需要每两周使用不同的背景数据临时运行一次,这会更改工作簿的计算。它每月运行10年。 10 * 12 * 60分钟很多时间等待可以独立运行的工作簿。我只有2台笔记本电脑,每台笔记本电脑都有8核,看来excel的浪费是每台笔记本电脑只使用一台。

要注意的是:工作簿不时依赖剪贴板。

想知道是否有人提出建议。 谢谢。

1 个答案:

答案 0 :(得分:0)

我认为PEH在这里碰到了头。也许Excel不是适合该工作的工具。在Excel的世界中,我已经看到事情开始很简单,却变得异常复杂。通常,只需使用R或Python,事情就可以大大简化,并且完成速度快数千倍。诚然,做出切换需要一些努力,但这是完全值得的。如果要坚持使用Excel,并在同一台计算机上运行多个Excel实例,请考虑下面列出的4个选项。

1. Alt + Open Excel

The first, and also my favorite method is the ALT + Open method. It works as follows:
Right click on the Excel icon in the taskbar. As the menu appears, hold down the ALT-key and left-click on the ‘Excel’ menu option.
New Instance Excel - Alt Open - 1.1

Hold down the ALT-key until the below window pops up. Press Yes to open a new instance.
New Instance Excel - Alt - Open - 1.2
Tip: you can also hold down the ALT-key, hoover your mouse over the Excel icon in the taskbar and click your scroll-button. This has the same effect and takes even less clicks.

2. Run Window

One of the quickest ways to open a new Excel Instance is using the Run window. To do this:

    Click Start -> enter ‘Run’ -> fill in “Excel.exe /x” and press enter.
    Or on Windows 10: enter “Excel.exe /x” in the start menu and press enter.

New Instance Excel - Start Window - 2.1

A new Excel instance will open.

3. Use VBA

This method makes use of VBA. Run below VBA code to open a second Excel instance. Do note, this method does not show a pop-up to indicate you opened a new instance.
Sub OpenNewExcelInstance()

Dim xlApp As Excel.Application
Set xlApp = New Excel.Application
xlApp.Workbooks.Add
xlApp.Visible = True
Set xlApp = Nothing

End Sub

4. Edit the Registry: Force Excel to Open in a New Instance by Default

This section explains how to open each Excel spreadsheet in a new instance by configuring a registry key. From all methods, this one involves the most steps to configure. However, if you need Excel to open a new instance by default, this method may be worth your while.
Note: this method only works when you use the Excel icon to open a new spreadsheet. When opening a new spreadsheet from within a file by using File -> Open, the file still opens in the current Excel instance. The same happens when you open a file from within the file explorer.