简体   繁体   English

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

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

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?我该如何解决这个问题?

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.现在,如果有人想同时更改主数据选项卡中的值,请检查布尔值是否设置为 true。 If yes, then you have to wait, if not, you can write the data.如果是,则必须等待,如果不是,则可以写入数据。

Adding to Manuel Allenspach's response, my suggestion is to create a queue.除了 Manuel Allenspach 的回应之外,我的建议是创建一个队列。

Queue should have a spot for user processing and other spots for users waiting.队列应该有一个供用户处理的地方和其他用户等待的地方。

Than, before running code, you should include a check to make sure no two users have their macros updating database at same time.比,在运行代码之前,您应该包括检查以确保没有两个用户同时更新数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM