|
Sub a()
Dim cnn As Object
Dim Sql As String, bt$, SH
bt = "序号,房号,销售日期"
Set cnn = CreateObject("ADODB.CONNECTION")
For Each SH In Sheets
If SH.Name <> ActiveSheet.Name Then
Sql = Sql & "SELECT " & bt & " FROM [" & SH.Name & "$A1:BP] WHERE 房号 is not null UNION ALL "
End If
Next
Sql = Left(Sql, Len(Sql) - 11)
cnn.Open "Provider=Microsoft.ACE.OleDb.12.0;Extended Properties='Excel 12.0;HDR=YES'; Data Source=" & ThisWorkbook.FullName
Range("A2:Z999").ClearContents
[A2].CopyFromRecordset cnn.Execute(Sql)
cnn.Close: Set cnn = Nothing
End Sub
BT 变量定义标题字段,这些字段必须在每个表格中都有,并且是统一的,
比如有的是姓名,有的是业主姓名,这个不行的,需要统一字段标题。
|
评分
-
1
查看全部评分
-
|