|
Sub limonet()
Dim Cn As Object, Arr As Variant, i%, Dic As Object
Set Dic = CreateObject("scripting.dictionary")
Set Cn = CreateObject("Adodb.Connection")
If Application.Version < 12 Then
Cn.Open "Provider=Microsoft.jet.OLEDB.4.0;Extended Properties=Excel 8.0;Data Source=" & ThisWorkbook.FullName
Else
Cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties=Excel 12.0;Data Source=" & ThisWorkbook.FullName
End If
Arr = Cn.Execute("Select * From [Sheet1$A:C] Where 日期>0 Or [收/支]<>''").GetRows(, , Array("日期", "收/支"))
For i = 0 To UBound(Arr, 2)
If Arr(1, i) <> "" Then
If IsNull(Arr(0, i)) Then Arr(0, i) = Arr(0, i - 1)
If Month(Arr(0, i)) = [F2] Then Dic(Arr(0, i)) = ""
End If
Next i
Range("F4").Resize(Dic.Count) = Application.Transpose(Dic.keys)
End Sub |
|