如何允许多个用户通过Userform输入而不覆盖冲突

时间:2016-04-11 21:32:09

标签: excel-vba vba excel

我创建了一个包含userform的共享工作簿,该用户窗体具有VBA代码以将输入数据传输到工作表。但是,当多个用户输入数据时,“解决冲突”对话框显示如下:

您对工作表的更改" SrOfcSpc"从'''更改细胞A4到' 2016年4月15日'   John Doe发生的冲突变化 - 4/11/16 3:44 PM改变了A4的细胞     ''到' 4/11 / 2016'

如何防止这种情况发生,以便多个用户可以同时输入?下面是我现有代码的片段。谢谢。

lrCD4 = Sheets("SrOfcSpc").Range("A" & Rows.Count).End(xlUp).Row
Sheets("SrOfcSpc").Cells(lrCD4 + 1, "A").Value = TextBox43.Text
Sheets("SrOfcSpc").Cells(lrCD4 + 1, "B").Value = TextBox44.Text
Sheets("SrOfcSpc").Cells(lrCD4 + 1, "C").Value = TextBox25.Text
Sheets("SrOfcSpc").Cells(lrCD4 + 1, "D").Value = TextBox26.Text
Sheets("SrOfcSpc").Cells(lrCD4 + 1, "E").Value = TextBox27.Text
Sheets("SrOfcSpc").Cells(lrCD4 + 1, "F").Value = TextBox31.Text
Sheets("SrOfcSpc").Cells(lrCD4 + 1, "G").Value = TextBox23.Text
Sheets("SrOfcSpc").Cells(lrCD4 + 1, "H").Value = TextBox24.Text
Sheets("SrOfcSpc").Cells(lrCD4 + 1, "I").Value = TextBox29.Text
Sheets("SrOfcSpc").Cells(lrCD4 + 1, "J").Value = TextBox30.Text
Sheets("SrOfcSpc").Cells(lrCD4 + 1, "K").Value = TextBox195.Text
Sheets("SrOfcSpc").Cells(lrCD4 + 1, "L").Value = TextBox196.Text
Sheets("SrOfcSpc").Cells(lrCD4 + 1, "M").Value = TextBox204.Text
Sheets("SrOfcSpc").Cells(lrCD4 + 1, "N").Value = TextBox203.Text
Sheets("SrOfcSpc").Cells(lrCD4 + 1, "O").Value = TextBox200.Text
Sheets("SrOfcSpc").Cells(lrCD4 + 1, "P").Value = TextBox199.Text
Sheets("SrOfcSpc").Cells(lrCD4 + 1, "Q").Value = TextBox198.Text
Sheets("SrOfcSpc").Cells(lrCD4 + 1, "R").Value = TextBox197.Text
Sheets("SrOfcSpc").Cells(lrCD4 + 1, "S").Value = TextBox202.Text
Sheets("SrOfcSpc").Cells(lrCD4 + 1, "T").Value = TextBox201.Text
Sheets("SrOfcSpc").Cells(lrCD4 + 1, "U").Value = TextBox205.Text

1 个答案:

答案 0 :(得分:0)

如果它帮助其他人寻求解决方案。我从另一个工作板上的用户那里找到了以下解决方案。

Private Sub Save_Click()
ActiveWorkbook.Sheets("sheetname").Activate
Range("A1").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ThisWorkbook.Save