瀏覽單個文章
asccpu
Master Member
 

加入日期: Jan 2002
您的住址: U.S.S AGC
文章: 1,669
用前人說的Excel,排序完後,RUN下面這段VBA,這是我之前要找出同名同姓的資料,而給別人寫的一段,我是不知有沒有用,我RUN時是沒用,可能我不會使用吧(我真不知要如何去RUN它 )

我不會VB,所以叫別人寫,不過看程式運作很單純,把前一筆COPY到別處再比對下一筆,同則跳過,不同則COPY到別處,一直下去。



Sub filter()
Dim count_ As Integer
Dim i As Integer
Dim j As Integer

i = 2
j = 2

Sheets(2).Cells(1, 1).Value = Sheets(1).Cells(1, 1).Value
count_ = 0

Do While Not Sheets(1).Cells(i, 1).Value = ""

Do While Not Sheets(2).Cells(j, 1).Value = ""
If Sheets(1).Cells(i, 1).Value = Sheets(2).Cells(j, 1).Value Then
count_ = count_ + 1
End If

j = j + 1
Loop

If count_ = 0 Then
Sheets(2).Cells(j, 1).Value = Sheets(1).Cells(i, 1).Value
End If

count_ = 0
i = i + 1
j = 2
Loop

result = MsgBox("已篩選完成", vbOKOnly, "系統訊息")
Sheets(2).Activate
Range("A1").Select

End Sub
__________________
辭源數位化計劃啟始於2014年1月。請拜訪成果。
舊 2004-10-21, 12:16 PM #9
回應時引用此文章
asccpu離線中