设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 1562|回复: 2
打印 上一主题 下一主题

请各位高人帮帮忙!

[复制链接]
跳转到指定楼层
1#
发表于 2007-5-16 06:16:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
通过点击<停留>表中的发出按钮来实现,<停留>表中与<发出>表中重复的数据所在行自动删掉,目前只能删掉数据,而不能删掉整行.请高手帮我解决.


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
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2007-5-16 17:44:00 | 只看该作者
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 match is true then delete row.








Rows(Sheets("停留").Cells(iCtr, 1).Row).Delete         


  ' 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
3#
 楼主| 发表于 2007-5-16 20:05:00 | 只看该作者
上述问题已经解决了,非常感谢!!!

能否再请教一个问题?

<发出>表中不与<停留>表里的重复数据能不能显示出来?(如变颜色之类的)

谢谢您的鼓励!!!

            NEVER GIVE UP!!!



您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-9-21 16:40 , Processed in 0.090164 second(s), 27 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表