|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
做个简单的样式供参考
Sub demo()
Sheet3.Activate
Rows("1:10000").Delete Shift:=xlUp
datestr = InputBox("请输入间隔日期(格式:yyyy-mm-dd,yyyy-mm-dd),第一日期小于第二日期")
date1 = Split(datestr, ",")(0)
date2 = Split(datestr, ",")(1)
cnn = "OLEDB;Provider=Microsoft.Ace.oledb.12.0;extended properties='excel 12.0;HDR=yes';data source=" & ThisWorkbook.FullName
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=cnn, Destination:=Range("$a$1")).QueryTable
.CommandText = "select 客户名称,count(订单号) as 订餐次数 from [月订单$] where 发货时间 between '" & date1 & "' and '" & date2 & "' group by 客户名称"
.ListObject.DisplayName = "表2"
.Refresh BackgroundQuery:=False
End With
End Sub |
|