|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
也是从别人帖子里看得,看不太懂,还请大神们帮忙给解释一下
Sub 按钮1_单击()
Dim oCnn As Object
Dim sSQL As String, i, j
Set oCnn = CreateObject("adodb.connection")
oCnn.Open "provider=microsoft.jet.oledb.4.0;extended properties='excel 8.0;hdr=no;imex=1';data source=" & ThisWorkbook.FullName
For i = 1 To 12
sSQL = "(select f1,(year(f9) & month(f9)) as f2,sum(iif(val(f15)=0,f5,f16)) as f3,sum(f15) as f4 from [出货清单$d3:s" & Sheets("出货清单").[d65536].End(xlUp).Row & "] where year(f9)=" & Sheets("销售利润情况统计").[k1] & " and month(f9)=" & i & " group by f1,(year(f9) & month(f9)))"
sSQL = "select b.f3,b.f4 from [销售利润情况统计$b5:b" & Sheets("销售利润情况统计").[b65536].End(xlUp).Row & "] a left join " & sSQL & " b on (a.f1=b.f1 and a.f1<>'')"
Sheets("销售利润情况统计").Cells(5, i + 3 + j).CopyFromRecordset oCnn.Execute(sSQL)
j = j + 4
Next
oCnn.Close
Set oCnn = Nothing
End Sub
这里面f1啊、f9啊、f15啊、f4啊都是什么意思,为什么这么写就可以统计出来,是不是代表数据库里什么东西,还望大神们帮忙给解释一下,小女子谢过了
|
|