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