0
這裏有一個難以理解的代碼,我可以搜索兩個標準,但我不能爲我的生活改變這一點,以允許我在兩個不同的列中搜索兩個標準。即H和AC。基於兩列中的兩個條件複製列和行
那麼兩者的符合這些行復制到一個新的工作表
Dim a As String, b As String
a = InputBox("Enter first criteria")
b = InputBox("enter second criteria")
ActiveSheet.UsedRange.AutoFilter Field:=3, Criteria1:=a
ActiveSheet.UsedRange.AutoFilter Field:=5, Criteria1:=b
ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible).Copy
Workbooks.Add
Range("A2").PasteSpecial
x = Cells(Rows.Count, 8).End(xlUp).Row
Range("H" & x + 1).Formula = "=sum(H2:H" & x & ")"
Range("H" & x + 1).AutoFill Destination:=Range("H" & x + 1 & ":BC" & x + 1), Type:=xlFillDefault
ActiveWorkbook.SaveAs Filename:="Data for " & a & " and " & b & ".xls"
ActiveWorkbook.Close True
ActiveSheet.UsedRange.AutoFilter
MsgBox "Complete" & Chr(10) & " check the file Data for " & a & " and " & b
End Sub