Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
电子表格中的VBA代码不允许多用户访问excel_Excel_Vba - Fatal编程技术网

电子表格中的VBA代码不允许多用户访问excel

电子表格中的VBA代码不允许多用户访问excel,excel,vba,Excel,Vba,我有一个电子表格,一个部门将扫描一个样本,并在扫描(发送)时在旁边的栏中加盖时间和日期戳。然后,下一个部门会将样本扫描到另一列,并在扫描(接收)时加盖时间和日期戳。我使用的代码如下所示,但由于受到保护,我不能让两个人同时编辑电子表格。我能做些什么来允许这个吗 Private Sub Worksheet_Change(ByVal Target As Range) ActiveSheet.Protect ("Password"), UserInterfaceOnly:=True 'Only wr

我有一个电子表格,一个部门将扫描一个样本,并在扫描(发送)时在旁边的栏中加盖时间和日期戳。然后,下一个部门会将样本扫描到另一列,并在扫描(接收)时加盖时间和日期戳。我使用的代码如下所示,但由于受到保护,我不能让两个人同时编辑电子表格。我能做些什么来允许这个吗

Private Sub Worksheet_Change(ByVal Target As Range)

ActiveSheet.Protect ("Password"), UserInterfaceOnly:=True

'Only write a timestamp of an odd column changes (because the timestamps go in the even columns)
If Target.Column Mod 2 > 0 Then

    'Get the first part of the address, to get the actual column being changed
    Dim columnAddress As String
    columnAddress = Target.Address

    If InStr(columnAddress, ":") > 0 Then
        columnAddress = Left(columnAddress, InStr(columnAddress, ":") - 1)
    End If

        If Not ActiveSheet.Range(columnAddress).Formula = "" Then

        'Write the timestamp for the previous column
        ActiveSheet.Range(columnAddress).Offset(0, 1).Formula = Now

        Else
            ActiveSheet.Range(columnAddress).Offset(0, 1).Formula = ""
        End If
End If

End Sub

我强烈建议您在这里使用ADO。如果您这样做,您将拥有一个远程Excel工作簿(或.mdb,如果您愿意),作为您的数据库,“子”工作簿(或Excel加载项)将向该数据库写入相关数据,如果需要,还将从中读取数据


这里提供了VBA中ADO的良好概述:。

我强烈建议您在这里使用ADO。如果您这样做,您将拥有一个远程Excel工作簿(或.mdb,如果您愿意),作为您的数据库,“子”工作簿(或Excel加载项)将向该数据库写入相关数据,如果需要,还将从中读取数据


这里提供了VBA中ADO的良好概述:。

为什么要使用电子表格来执行数据库作业?正在生成数据库,这是一个bandaid。为什么要使用电子表格来执行数据库作业?正在生成数据库,这是一个bandaid。