|
- Sub ll1()
- Dim T As Date
- T = Time
- Debug.Print T
- Dim Cn As ADODB.Connection
- Dim Rs As ADODB.Recordset
- Dim Sql As String
- Dim oDate As Date
- Set Cn = New ADODB.Connection
- Set Rs = New Recordset
- oDate = "2023/3/4"
-
- Cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties='Excel 12.0;HDR=yes';data source=" & ThisWorkbook.FullName
- 'Set Rs = Cn.Execute("Select a.日期,a.日出,b.日出,c.日出,d.日出,e.日出,f.日出,g.日出,h.日出 from [兰州$A5:D2000]a,[珠海$A5:D2000]b,[武汉$A5:D2000]c,[北京$A5:D2000]d ,[抚远$A5:D2000]e,[漠河$A5:D2000]f,[三沙$A5:D2000]g,[喀什$A5:D2000]h where a.日期 = #2023/3/4# and b.日期 = #2023/3/4# and c.日期 = #2023/3/4# and d.日期 = #2023/3/4# ")
-
- Sql = "Select a.日期,a.日出,b.日出,c.日出,d.日出 "
- Sql = Sql & ",e.日出,f.日出,g.日出,h.日出 "
-
- Sql = Sql & " from [兰州$A5:D20]a,[珠海$A5:D20]b,[武汉$A5:D20]c,[北京$A5:D20]d "
- Sql = Sql & ",[抚远$A5:D20]e,[漠河$A5:D20]f "
- Sql = Sql & ",[三沙$A5:D20]g,[喀什$A5:D20]h "
- Debug.Print Sql
- Sql = Sql & " where a.日期 = #2022/3/4# and b.日期 = #2022/3/4# and c.日期 = #2022/3/4# and d.日期 = #2022/3/4# "
- Sql = Sql & " and e.日期 = #2022/3/4# and f.日期 = #2022/3/4# "
- Sql = Sql & " and g.日期 = #2022/3/4# and h.日期 = #2022/3/4# "
- Debug.Print Sql
- Set Rs = Cn.Execute(Sql)
- 'Rs.MoveFirst
- Sheet3.Cells.Clear
- Sheet3.Cells(2, 1).CopyFromRecordset Rs
- Debug.Print Time
- Debug.Print T
- Debug.Print Format(Time - T, "h:mm:ss")
-
- End Sub
复制代码
|
|