电子表格中的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。