|
通过点击<停留>表中的发出按钮来实现,<停留>表中与<发出>表中重复的数据所在行自动删掉,目前只能删掉数据,而不能删掉整行.请高手帮我解决.
Sub DelDups_TwoLists()
Dim iListCount As Integer
Dim iCtr As Integer
' Turn off screen updating to speed up macro.
Application.ScreenUpdating = False
' Get count of records to search through (list that will be deleted).
iListCount = Sheets("停留").Range("A1:A100").Rows.Count
' Loop through the "master" list.
For Each x In Sheets("发出").Range("A1:A10")
' Loop through all records in the second list.
For iCtr = 1 To iListCount
' Do comparison of next record.
' To specify a different column, change 1 to the column number.
If x.Value = Sheets("停留").Cells(iCtr, 1).Value Then
' If match is true then delete row.
Sheets("停留").Cells(iCtr, 1).Delete xlShiftUp
' Increment counter to account for deleted row.
iCtr = iCtr + 1
End If
Next iCtr
Next
Application.ScreenUpdating = True
MsgBox "发出成功"
End Sub
Private Sub CommandButton1_Click()
Dim iListCount As Integer
Dim iCtr As Integer
' Turn off screen updating to speed up macro.
Application.ScreenUpdating = False
' Get count of records to search through (list that will be deleted).
iListCount = Sheets("停留").Range("A1:A100").Rows.Count
' Loop through the "master" list.
For Each x In Sheets("发出").Range("A1:A10")
' Loop through all records in the second list.
For iCtr = 1 To iListCount
' Do comparison of next record.
' To specify a different column, change 1 to the column number.
If x.Value = Sheets("停留").Cells(iCtr, 1).Value Then
' If matc |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|