用VBA查询我的excel工作表 [英] Query my excel worksheet with VBA
本文介绍了用VBA查询我的excel工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可以使用VBA查询工作表吗?
Is it possible to query a worksheet using VBA?
我想能够选择时间列中的所有值,即(00:00)WHERE天等于例如:Saturday
I want to be able to select all the values in the time column i.e. (00:00) WHERE the day equals for example: Saturday
我有任何方法可以做到这一点,一个教程将是非常有用的。
I there any way to do this, a tutorial would be really helpful.
谢谢
推荐答案
您可以编程创建一个自动筛选器,然后选择匹配的值:
You can programmtically create an AutoFilter, then select the matching values:
Dim ws As Worksheet: Set ws = ActiveSheet
With ws
.AutoFilterMode = False
.Range("1:1").AutoFilter
.Range("1:1").AutoFilter field:=2, Criteria1:="=Saturday", Operator:=xlAnd
With .AutoFilter.Range
On Error Resume Next ' if none selected
.Offset(1).Resize(.Rows.Count - 1).Columns(2).SpecialCells(xlCellTypeVisible).Select
On Error GoTo 0
End With
.AutoFilterMode = False
End With
这篇关于用VBA查询我的excel工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文