Public Sub CopyData()
' To use Dictionary, add Microsoft.Script.Runtime in Tools->Reference
Dim dataDict As New Dictionary
Dim ws As Worksheet, i As Integer, r As Long, lastR As Long, c As Long, keyString As String
lastR = 2
For i = 1 To 3
Set ws = Workbooks.Open("Your file").Worksheets(1)
' Step 1. Loop through all the rows
r = 2 ' Assume data starts at row 2
Do While ws.Cells(r, 1) <> ""
' Step 2. Check duplicates
' Step 2.1 Generate keys
c = 1
keyString = ""
Do While ws.Cells(r, c) <> ""
keyString = keyString & ws.Cells(r, c)
c = c + 1
Loop
' Step 2.2 Now check duplicates in dictionary
If dataDict.Exist(keyString) = False Then
' Copy data here
' Increment last row in the master workbook
lastR = lastR + 1
Else
' Duplicate found - Highlight or do whatever here
End If
r = r + 1
Loop
Next i
End Sub
用戶在識別副本時是否需要採取任何措施,或者只是提供信息的消息框? – barrowc 2010-04-29 01:52:28
barrowc 當用戶獲得消息框時,用戶必須單擊確定並查找條目。我有一個arraye公式,我會設置查找任何個人工作簿的主表,但如果有任何建議最適合我會去那 再次感謝 – sam 2010-04-30 09:59:40
大家好, 我想澄清我最初的問題可能來自任何救世主的解決方案。假設我爲每個用戶提供了3個excel表單,用於位於不同工作簿中的數據錄入,以避免出現excel共享工作簿問題。我還在另一個工作簿中提供了一張主表,當我希望在這些表上輸入單個數據時,精確地說,表1應該隨着用戶輸入它們而複製到主表中的表1的下一個可用行。我需要一個VBA代碼,可以不復制主表中的重複行,但突出顯示重複的行,並查找主要的初始記錄 – sam 2010-04-30 22:59:28