真的太棒了, 找到福音了。 非常感谢 =============== 版主:我现在想做成个生日查询的,麻烦您调试下代码,为什么这个类型不管怎么定义,问题不行: Sub ChaXun() '按输入的日期起止来查询职员的生日名单
Dim x As Object
Dim yy As Object
Dim strsql As String Set x = CreateObject("ADODB.Connection")
Set yy = CreateObject("ADODB.Recordset")
x.Open "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties='Excel 8.0';;Data Source=" & ThisWorkbook.FullName
strsql = "select * FROM [员工信息表$a2:k] WHERE 生日 between '" & Sheet5.Cells(4, 5) & "' and '" & Sheet5.Cells(4, 7) & "'"
yy.Open strsql, x, adOpenStatic, adOpenDynamic
Sheet5.Range("a8:z1000").ClearContents
Sheet5.[a8].CopyFromRecordset yy Set yy = Nothing: Set x = Nothing End Sub |