Excel精英培训网

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

[已解决]查询代码修改

[复制链接]
发表于 2017-3-21 07:35 | 显示全部楼层 |阅读模式
本帖最后由 走进EXCEL 于 2017-5-19 22:09 编辑


求助:查询代码修改(数组方法),谢谢!! 数组求助.rar (64.7 KB, 下载次数: 19)
发表于 2017-3-25 17:07 | 显示全部楼层    本楼为最佳答案   
成本价没做,很简单的,你自己练下手吧。
  1. Private Sub Worksheet_Change(ByVal T As Range)
  2. Dim rng As Range, r&, i&, n#
  3. If T.Address = "$P$1" Then
  4.   With Sheets(1)
  5.     r = .Columns(2).Find(T.Value).Row
  6.     For i = r To .Rows.Count
  7.       If .Cells(i, 2) <> "" Then Exit For
  8.       n = n + .Cells(i, 8) + .Cells(i, 15)
  9.     Next i
  10.     i = i - 1
  11.     Set rng = Union(.Range(.Cells(r, 2), .Cells(i, 2)), .Range(.Cells(r, 4), .Cells(i, 9)), .Range(.Cells(r, 11), .Cells(i, 16)))
  12.   End With
  13.   If [a65536].End(3).Row > 4 Then [a1].CurrentRegion.Offset(4).Clear
  14.   rng.Copy [a5]
  15. End If
  16. End Sub
复制代码
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-26 22:34 , Processed in 0.437627 second(s), 9 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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