|
- Sub demo()
- Dim conn As Object, connectionStr$, sqlStr$
-
- Set conn = CreateObject("Adodb.Connection")
-
- connectionStr = "Provider=MicroSoft.ACE.OLEDB.12.0;Extended Properties='excel 12.0;HDR=YES';Data Source=" & ThisWorkbook.FullName
-
- conn.Open connectionStr
-
- sqlStr = "SELECT 库房,供应商 FROM (SELECT 库房,供应商 FROM [流水表$] WHERE NOT 供应商 IN(SELECT 供应商 FROM [供应商删除$])) WHERE 库房 IN(SELECT 库房 FROM [库房保留$])"
-
- Application.ScreenUpdating = False
-
- Application.DisplayAlerts = False
- With ThisWorkbook.Worksheets.Add(after:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count))
-
- .Name = "流水表" & Format(Now, "yymmddhhmmss")
-
- .Range("A2").CopyFromRecordset conn.Execute(sqlStr)
-
- .Range("A1:B1").Value = Array("库房", "供应商")
- End With
-
- conn.Close
-
- Set conn = Nothing
-
- Application.DisplayAlerts = True
-
- Application.ScreenUpdating = True
- End Sub
复制代码
|
|