|
回复 1楼 ZWBZLJ 的帖子
Private Sub CommandButton1_Click()
Dim cnn, rst
Dim SQL As String
Set cnn = CreateObject("ADODB.connection")
Set rst = CreateObject("ADODB.recordset")
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties='Excel 8.0;';Data Source=" & ThisWorkbook.Path & "\高三.xls"
For i = 2 To Sheets("提取1").[B65536].End(xlUp).Row
SQL = "select * from [原稿$] as S2 where S2.姓名=" & "'" & Sheets("提取1").Cells(i, 2).Value & "'"
rst.Open SQL, cnn, 1, 1
Sheets("提取1").Cells(i, 1).CopyFromRecordset rst
rst.Close
Next i
cnn.Close
Set rst = Nothing
Set cnn = Nothing
End Sub |
|