excel - 在自动过滤器中使用数组
问题描述
rname 是我动态初始化的数组。
我在 vba 代码中得到了这个
运行时错误“1004”:应用程序定义或对象定义错误
For z=2 to lr2
k=0
if sh3.Cells(z,2)>1 Then
size=sh3.Cells(z,2).value2-1
Redim rname(size)
Do While z<z+sh3.Cells(z,2).value2 And k<sh3.Cells(z,2).value2-1
z=z+1
rname(k)=sh3.Cells(z,1).value2
k=k+1
Loop
With sh1.Range("A3")
.AutoFilter Field:=14, Criteria1:= sh.Cells(x,2).value2
.AutoFilter Field:=4, Criteria1:=rname()
End With
解决方案
我认为您AutoFilter
需要知道XlAutoFilterOperator
您的标准使用什么。试试看,请修改:
.AutoFilter Field:=4, Criteria1:=rname(), Operator:=xlFilterValues
推荐阅读
- alexa - 我们可以让Alexa在给定时间后像警报一样说出一句话吗?
- javascript - 如何从图像源字符串中获取源的一部分?
- pipeline - snakemake 总是在第 44 行报告“ MissingOutputException,5 秒后丢失文件:
- crystal-reports - 合并水晶报表组内的数据
- php - 我想在考试结果中显示第 1、第 2、第 3 的位置
- python - 与日期时间索引条件合并
- node.js - 来自节点 js 中 HTTPS 安装的问题
- aws-lambda - AWS Java Lambda 压缩 JSON 响应失败:“由于配置错误,执行失败:格式错误的 Lambda 代理响应”
- colors - 索引颜色内存大小与原始图像
- java - 使用深度优先搜索迭代回溯