需要过滤的原始数据需要帮助过滤两个时间之间的值,例如开始时间将是00:00到14:00,我需要过滤这些值之间的值,复制相应的数据并粘贴到另一个工作表中
Option Explicit
Sub Filter_My_Data()
Dim Data_sh As Worksheet
Dim Filter_Criteria_Sh As Worksheet
Dim Output_sh As Worksheet
Set Data_sh = ThisWorkbook.Sheets("Data")
Set Filter_Criteria_Sh = ThisWorkbook.Sheets("Filter_Criteria")
Set Output_sh = ThisWorkbook.Sheets("Output")
Output_sh.UsedRange.Clear
Data_sh.AutoFilterMode = False
Dim timelist() As long
Dim n As Integer
n = Application.WorksheetFunction.CountA(Filter_Criteria_Sh.Range("A:A")) - 2
ReDim timelist(n) As long
Dim i As Integer
For i = 0 To n
timelist(i) = Filter_Criteria_Sh.Range("A" & i + 2)
Next i
Data_sh.UsedRange.AutoFilter 3, timelist(), xlFilterValues
Data_sh.UsedRange.Copy Output_sh.Range("A1")
Data_sh.AutoFilterMode = False
MsgBox ("Data has been Copied")
End Sub
1条答案
按热度按时间htrmnn0y1#
按时间间隔筛选