|
Sub Macro1()
Dim myData As String, myTable As String, SQL As String, s$
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim i As Integer
myData = ThisWorkbook.Path & "\职工管理22.mdb"
myTable = "职工基本信息22"
Set cnn = New ADODB.Connection
With cnn
.Provider = "microsoft.jet.oledb.4.0"
.Open myData
End With
Set rs = New ADODB.Recordset
rs.Open myTable, cnn, adOpenKeyset, adLockOptimistic
s = ",1,2,4,5,7,8,10,11,12,"
[a1].CurrentRegion.ClearContents
For i = 1 To rs.RecordCount
If InStr(s, "," & i & ",") Then
m = m + 1
Cells(m, 1) = rs.Fields(0)
End If
rs.MoveNext
Next
rs.Close
cnn.Close
Set rs = Nothing
Set cnn = Nothing
End Sub |
|