|
Sub tqsj()
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 & "$a6:b28] where 销售='Total Room Sales房费:' or 销售='会议费' or 销售='迷你吧' or 销售='洗涤费' or 销售='杂项'or 销售='赔偿费' or 销售='西餐厅' UNION ALL "
Next
Sql = Left(Sql, Len(Sql) - 11)
rs.Open Sql, cnn, 1, 1
[b2:af12] = ""
For i = 1 To 31
[a2].Offset(0, i).CopyFromRecordset rs, 7
Next
cnn.Close: Set cnn = Nothing
End Sub
|
评分
-
1
查看全部评分
-
|