滤除电子表格中不需要的行
我有2个电子表格:
main.xlsx
和
drs.xlsx
他们需要join,但在join他们之前,我需要在drs.xlsx上使用VBA过滤掉一些行。
在main.xlsx上按下button时,如何根据以下条件过滤掉drs.xslx上的行(即忽略不符合此条件的任何内容):
Column A = "TW" or "W" Column C = "Windows 7" or "Windows XP" Column D = "Workstation-Windows"
这是你需要的吗?
Sub test() Dim wb As Workbook 'if drs is already opened Set wb = Workbooks("drs.xlsx") 'if drs not already opened 'Set wb = Workbooks.Open("C:\drs.xlsx") With wb.Worksheets("Sheet1") .AutoFilterMode = False With .Range("A1:D1") .AutoFilter Field:=1, Criteria1:="TW", Operator:=xlOr, Criteria2:="W" .AutoFilter Field:=3, Criteria1:="Windows 7", Operator:=xlOr, Criteria2:="Windows XP" .AutoFilter Field:=4, Criteria1:="Workstation-Windows" End With End With End Sub
select形状,说。 长方形:
创buildbutton,并添加文本:
分配macros: