Excel精英培训网

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

请求各位高手帮忙

[复制链接]
发表于 2017-8-14 15:23 | 显示全部楼层 |阅读模式
见附件 附件3.rar (34.32 KB, 下载次数: 6)
发表于 2017-8-14 17:01 | 显示全部楼层
  1. Sub test()
  2. Dim str$
  3. If Range("D3") <> "" Then str = "[总价]" & Range("D3")
  4. If Range("H3") <> "" Then str = IIf(Len(str) > 0, str & "and", "") & " [联系人] = " & "'" & Range("H3").Text & "'"
  5. If Range("e3") <> "" Then str = IIf(Len(str) > 0, str & " and", "") & " [税率] = " & Range("e3").Text
  6. If Range("g3") <> "" Then str = IIf(Len(str) > 0, str & " and", "") & " [合同类别] =  " & "'" & Range("g3").Text & "'"
  7. '就这么加进去。。。
复制代码

大概这样加进去
回复

使用道具 举报

 楼主| 发表于 2017-8-14 18:57 | 显示全部楼层

非常感谢高手的帮助,高水平就是高水平,我还有一个愿望比如“编号“这栏如果我只输入前两个或前7个字符,代码只按我输入的字符筛选那就更好了。
回复

使用道具 举报

 楼主| 发表于 2017-8-14 20:07 | 显示全部楼层
按您编写的代码,该语句如何变动If Range("b3") <> "" Then str = IIf(Len(str) > 0, str & " and", "") & " [编号] =  " & "'" & Range("b3").Text & "'"
使我输入”BJ“或”BJ-1702”时就能筛选出由其开头的所有记录。
回复

使用道具 举报

发表于 2017-8-15 08:02 | 显示全部楼层
lyslyslys1 发表于 2017-8-14 20:07
按您编写的代码,该语句如何变动If Range("b3")  "" Then str = IIf(Len(str) > 0, str & " and", "") & "  ...

If Range("D3") <> "" Then str = "[总价]" & Range("D3")
If Range("H3") <> "" Then str = IIf(Len(str) > 0, str & "and", "") & " [联系人] = " & "'" & Range("H3").Text & "'"
If Range("e3") <> "" Then str = IIf(Len(str) > 0, str & " and", "") & " [税率] = " & Range("e3").Text
If Range("g3") <> "" Then str = IIf(Len(str) > 0, str & " and", "") & " [合同类别] =  " & "'" & Range("g3").Text & "'"
If Range("b3") <> "" Then str = IIf(Len(str) > 0, str & " and", "") & " [编号]  like '" & Range("b3").Text & "%'"
'就这么加进去。。。注意like是区分大小写的

回复

使用道具 举报

 楼主| 发表于 2017-8-15 10:29 | 显示全部楼层
太感谢了[em17]
回复

使用道具 举报

 楼主| 发表于 2017-8-18 11:39 | 显示全部楼层
再麻烦高手:实际工作中每张工作表B列有的单元格有批注,怎样将批注也一同筛选到“高级筛选”表中呢?
回复

使用道具 举报

 楼主| 发表于 2017-8-18 13:41 | 显示全部楼层
发错楼层了!不好意思再麻烦高手:实际工作中每张工作表B列有的单元格有批注,怎样将批注也一同筛选到“高级筛选”表中呢?
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-20 01:05 , Processed in 0.857666 second(s), 11 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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