|
Sub a()
Dim f
f = Application.GetOpenFilename("EXCEL Files (*.xls), *.xls")
If f = False Then Exit Sub
Dim cnn As Object
Dim Sql As String, i%, arr, rs
Set cnn = CreateObject("ADODB.CONNECTION")
Set rs = CreateObject("adodb.Recordset")
cnn.Open "Provider=Microsoft.Jet.OleDb.4.0;Extended Properties='Excel 8.0;HDR=YES'; Data Source=" & f
For i = 1 To 31
Sql = Sql & "select 日营业额+0 from [" & i & "$a3:b17] where 项目='1房租' or 项目='C会务服务费' or 项目='6客房酒水收入' or 项目='D赔偿费' or 项目='P横幅' UNION ALL "
Next
Sql = Left(Sql, Len(Sql) - 11)
rs.Open Sql, cnn, 1, 1
[b4:af11] = ""
For i = 1 To 31
[a7].Offset(0, i).CopyFromRecordset rs, 5
Next
cnn.Close: Set cnn = Nothing |
评分
-
1
查看全部评分
-
|