2016-04-11 24 views
0

我已經創建了一個包含有VBA代碼輸入數據傳輸到工作表的用戶窗體共享工作簿。但是,如果多個用戶輸入數據,「解決衝突」對話框將顯示如下:我怎麼能允許多個用戶通過輸入用戶窗體,而不會覆蓋衝突

對工作表「SrOfcSpc」所做的更改已將單元格A4從「'更改爲'4/15/2016' 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 
+0

使用數據庫,或讓每個人都在不同的表中輸入數據。 http://blog.contextures.com/archives/2008/11/18/avoiding-shared-workbooks-in-excel/ –

+0

我試圖具有大家的數據去到不同的片選項,但它不工作。我有多個選項卡(即Recruiter等)的用戶窗體設置,用戶根據其角色類型選擇適用的選項卡。因此,即使招聘人員#1輸入他們的數據,並且將其寫入到招聘人員1的單獨表格中,如果我嘗試並指示招聘人員2的vba代碼爲他們單獨選擇標籤,它仍然被定向到招聘人員1的表格,因爲他們都是在UserForm上使用相同的文本框字段。還有其他建議嗎? –

回答

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 
相關問題