vba - 使用变量表示列号的自动过滤器
问题描述
我正在尝试用 Long 替换命名列“I”,在下面的代码中进行自动过滤:
With Range("I1", Range("I" & Rows.Count).End(xlUp))
.AutoFilter 1, TeamString
End With
我已将“filterColumn”定义为 Long。但是我得到一个运行时错误:对象失败的方法范围,因为我在下面对变量的引用不正确:
With Range(Cells(filterColumn, 1), Range(filterColumn & Rows.Count).End(xlUp))
.AutoFilter 1, filterEntry
End With
解决方案
请尝试下一个方法:
With Range(Cells(1, filterColumn), Cells(Rows.Count, filterColumn).End(xlUp))
.AutoFilter 1, filterEntry
End With
Cells
参数RowIndex
后跟ColumnIndex
.
推荐阅读
- javascript - 遍历对象数组以过滤特定数据
- xamarin - 从服务打开 Activity
- google-data-studio - Google Data Studio:通过 URL 中的参数过滤报告数据
- c++ - UWP 从 C++ 访问 WindowsRuntimeStreamExtensions 类?
- swift - 理解 Swift 中的双精度和整数
- javascript - 如何在本地 javascript 文件中使用 CDN 中的对象?
- asp.net - 使用 .net Framework 4 及更高版本(而不是 .NET Core)的微服务
- python - 无法在 vscode 上的 ipynb 文件中渲染图像
- ruby - 在类之间携带记录器实例
- c# - 使用 EF Core 加载和持久化 In-Memory SQLite 数据库