|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 对账单()
Application.ScreenUpdating = False
Set conn = CreateObject("adodb.connection")
conn.Open "provider=microsoft.jet.oledb.4.0;extended properties='excel 8.0;imex=1';data source=" & ActiveWorkbook.FullName
Range("A7:H50").ClearContents
Sql = "select 发货日期,客户,商品,数量,单价,金额,其他,贷方,余额 from [" & [B1] & "$] " & _
"where MONTH(发货日期) >= cdate('" & [D1] & "') AND MONTH(发货日期) <= cdate('" & [F1] & "') "
[A8].CopyFromRecordset conn.Execute(Sql)
[I7] = [I8] + [H8] - [F8] - [G8]
[A7] = "上期余额"
[A52] = "杭州美益天"
conn.Close
Set conn = Nothing
Application.ScreenUpdating = True
End Sub
Range("A7:H50").ClearContents 这行代码有问题,把50改成20 ,这是你清楚内容的区域
|
|