|
本帖最后由 lufabao 于 2016-3-25 11:41 编辑
想把【图1】表中范围日期内的条目查询出表示在【图2】表中
现在查询 只会复制“会员缴费明细表”几个字
请教代码错在哪
----------------------------------------------------------------------------------------------
Sub test()
Dim xR As Range
Dim D1, D2 As Date
D1 = InputBox("开始日期")
D2 = InputBox("结束日期")
If D1 > D2 Then
MsgBox ("日期输入錯誤")
Exit Sub
End If
Set xR = Range("会员缴费表!I3").CurrentRegion
With xR
.AutoFilter
.AutoFilter Field:=1, Criteria1:=">=" & D1, Operator:=xlAnd, Criteria2:="<=" & D2
Range("会员缴费表!A3").CurrentRegion.Copy
Range("会员缴费查询!a5").PasteSpecial xlValues
.AutoFilter
End With
End Sub
----------------------------------------------------------------------------------------------
这样试试,你的日期在第9列啊 - Sub test()
- Dim xR As Range
- Dim D1, D2 As Date
- D1 = InputBox("开始日期")
- D2 = InputBox("结束日期")
- If D1 > D2 Then
- MsgBox ("日期输入錯誤")
- Exit Sub
- End If
- With Cells.CurrentRegion
- .AutoFilter Field:=9, Criteria1:=">=" & D1, Operator:=xlAnd, Criteria2:="<=" & D2
- .SpecialCells(xlCellTypeVisible).Copy Sheet11.Range("a5")
- .AutoFilter
- End With
- End Sub
复制代码
|
|