vba 多个用户如何在共享的 excel 文件上运行宏?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21417130/
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 01:35:52  来源:igfitidea点击:

How can multiple users run macros on a shared excel file?

excelvbaexcel-vba

提问by user3246361

I have an excel file on shared location where multiple users (4 in this case) are accessing the file at the same time.

我在共享位置有一个 excel 文件,其中多个用户(在本例中为 4 个)同时访问该文件。

This file has a “Master data” tab where all the base data is there and then there are 4 identical tabs (one for each user).

该文件有一个“主数据”选项卡,其中包含所有基本数据,然后有 4 个相同的选项卡(每个用户一个)。

Each user tab has a set of filters using which the user will be able to extract relevant data based on the filters selected and can add or edit the rows. Once the user is done editing/adding rows, user will submit the data which will get updated/appended in the master data tab.

每个用户选项卡都有一组过滤器,用户可以使用这些过滤器根据选择的过滤器提取相关数据,并可以添加或编辑行。用户完成编辑/添加行后,用户将提交将在主数据选项卡中更新/附加的数据。

Users can select same or different options in the filters. I am facing errors when multiple users click on the submit button (macro) at the same time.

用户可以在过滤器中选择相同或不同的选项。当多个用户同时单击提交按钮(宏)时,我遇到了错误。

How can I resolve this?

我该如何解决这个问题?

回答by CommonGuy

Like some comments say, Excel is not designed for this...

就像一些评论说的那样,Excel 不是为此而设计的......

But if you want to use Excel, i would recommend something like this:

但是如果你想使用Excel,我会推荐这样的:

Every time someone writes in the master data, you have to "lock" the master data tab. Just put a boolean in a cell, set it to true while you are writing and back to false as soon as you finished altering the master data tab.

每次有人写入主数据时,您都必须“锁定”主数据选项卡。只需在单元格中放置一个布尔值,在写入时将其设置为 true,并在完成更改主数据选项卡后立即将其设置为 false。

Now, if someone wants to change values in the master data tab at the same time, check if the boolean is set to true. If yes, then you have to wait, if not, you can write the data.

现在,如果有人想同时更改主数据选项卡中的值,请检查布尔值是否设置为 true。如果是,则必须等待,如果不是,则可以写入数据。