Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1775|回复: 1

[已解决]请求坛里的老师帮忙!判断添加数据前,是否已有相同项目!

[复制链接]
发表于 2016-9-29 23:35 | 显示全部楼层 |阅读模式
2016-09-30_232206.jpg
请求坛里的老师帮忙!判断添加数据前,是否已有相同项目!
添加数据,判断终止重复添加.rar (142.99 KB, 下载次数: 2)
发表于 2016-9-30 10:41 | 显示全部楼层    本楼为最佳答案   
SSS窗体的Listview1双击事件改下。
  1. Private Sub ListView1_DblClick()
  2. Dim Z, S, a%
  3. Set S = ListView1
  4. With ZZZ.ListView1
  5.     For a = 1 To .ListItems.Count
  6.         If .ListItems(a).SubItems(1) = S.SelectedItem.SubItems(1) Then
  7.             MsgBox "【" & S.SelectedItem.SubItems(1) & "】已存在!", vbExclamation: Exit Sub
  8.         End If
  9.     Next
  10.    Set Z = .ListItems.Add()
  11.             Z.Text = .ListItems.Count
  12.             Z.SubItems(1) = S.SelectedItem.SubItems(1)
  13.             Z.SubItems(2) = S.SelectedItem.SubItems(2)
  14.             Z.SubItems(3) = S.SelectedItem.SubItems(3)
  15.             Z.SubItems(4) = S.SelectedItem.SubItems(4)
  16.             Z.SubItems(5) = S.SelectedItem.SubItems(5)
  17.             Z.SubItems(6) = S.SelectedItem.SubItems(6)
  18.             Z.SubItems(7) = S.SelectedItem.SubItems(7)
  19. End With
  20. End Sub
复制代码
回复

使用道具 举报

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

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-23 01:02 , Processed in 0.305938 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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