首页 > 解决方案 > 一个更好的自动过滤表代码到另一个表 Visual basic Excel

问题描述

'请谁知道更好的自动过滤器代码,告诉我如何自动过滤到特定列'不是到工作表的末尾

Sub copy_filter_data()

Dim count_col, count_row As Integer
Dim orig, output As Worksheet

Worksheets("Sheet1").Activate

Set orig = ThisWorkbook.Sheets("Sheet1")
Set output = ThisWorkbook.Sheets("Sheet2")

count_col = WorksheetFunction.CountA(Range("A5", Range("A5").End(xlToRight)))
count_row = WorksheetFunction.CountA(Range("A5", Range("A5").End(xlDown)))

ActiveSheet.Range("A5").AutoFilter Field:=18, Criteria:=Cells(5, 35).Value
orig.Range(Cells(5, 1), Cells(count_row, count_col)).SpecialCells(xlCellTypeVisible).Copy
output.Cells(5, 1).PasteSpecial xlPasteValues
Application.CutCopyMode = False


End Sub

标签: excelvbaautofilter

解决方案


推荐阅读