Excel精英培训网

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

[已解决]重新求助一下

[复制链接]
发表于 2017-7-9 12:35 | 显示全部楼层 |阅读模式
请看附件谢谢!!!!!!
最佳答案
2017-7-10 11:35
  1. Private Sub Worksheet_Change(ByVal Target As Range)
  2.     If Target.Count > 1 Then Exit Sub
  3.     If Target.Row < 8 Or Target.Column <> 4 Then Exit Sub
  4.     r = Target.Row: x = Cells(r, "x")
  5.     Set d = CreateObject("scripting.dictionary")
  6.     Application.EnableEvents = False
  7.     If x <> "" Then
  8.         With Sheets("3")
  9.             For c = 1 To .Cells(1, 256).End(xlToLeft).Column
  10.                 d(.Cells(1, c).Value) = ""
  11.             Next
  12.             For c = 1 To .Cells(1, 256).End(xlToLeft).Column
  13.                 If .Cells(1, c) = "" Then Exit For
  14.             Next
  15.             If Not d.exists(x) Then .Cells(1, c).Resize(3) = Application.Transpose(Array(x, "甲", "乙"))
  16.         End With
  17.     End If
  18.     Application.EnableEvents = True
  19. End Sub
复制代码

666.rar

7.81 KB, 下载次数: 21

 楼主| 发表于 2017-7-9 16:03 | 显示全部楼层
回复

使用道具 举报

 楼主| 发表于 2017-7-9 20:26 | 显示全部楼层
回复

使用道具 举报

发表于 2017-7-10 11:35 | 显示全部楼层    本楼为最佳答案   
  1. Private Sub Worksheet_Change(ByVal Target As Range)
  2.     If Target.Count > 1 Then Exit Sub
  3.     If Target.Row < 8 Or Target.Column <> 4 Then Exit Sub
  4.     r = Target.Row: x = Cells(r, "x")
  5.     Set d = CreateObject("scripting.dictionary")
  6.     Application.EnableEvents = False
  7.     If x <> "" Then
  8.         With Sheets("3")
  9.             For c = 1 To .Cells(1, 256).End(xlToLeft).Column
  10.                 d(.Cells(1, c).Value) = ""
  11.             Next
  12.             For c = 1 To .Cells(1, 256).End(xlToLeft).Column
  13.                 If .Cells(1, c) = "" Then Exit For
  14.             Next
  15.             If Not d.exists(x) Then .Cells(1, c).Resize(3) = Application.Transpose(Array(x, "甲", "乙"))
  16.         End With
  17.     End If
  18.     Application.EnableEvents = True
  19. End Sub
复制代码

新建Microsoft Office Excel 工作表.rar

15.43 KB, 下载次数: 5

评分

参与人数 1 +1 收起 理由
171774040 + 1 赞一个

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-24 05:24 , Processed in 0.335202 second(s), 15 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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