Sub CC()
Set cn = CreateObject("adodb.connection")
cn.Open "provider=microsoft.jet.oledb.4.0;extended properties=excel 8.0;data source=" & ThisWorkbook.FullName
'Sql = "SELECT 序号,户名,开户行名称,卡/折号,发票事由,金额-300,填报人,填报日期,项目类别,发票张数,附件张数,打款帐户,是否固定资产,备注 FROM [发票收集登记表$a2:n] WHERE 户名 IN ('czx','hsm','mcc','xz','qh','hlg','cyj','tq','llm') AND 发票事由 like '%" & 工资 & "'"
Sql = "SELECT* FROM [发票收集登记表$a2:n] WHERE 户名 IN ('czx','hsm','mcc','xz','qh','hlg','cyj','tq','llm') AND 发票事由 like '%" & 工资 & "'"
With Sheets.Add(after:=Sheets(Sheets.Count))
.Name = "汇总表二"
Rows(1).Copy .Rows(1): Rows(2).Copy .Rows(2)
.Range("a3").CopyFromRecordset cn.Execute(Sql)
End With
End Sub |