Sub 按钮1_Click()
Dim url, html
n = 1
url = ">
没实测,链接csv是不是应该这样写
strlj = "Provider=MicrosoftJetOLEDB40;Extended Properties='text;IMEX=1;HDR=yes;FMT=Delimited;';Data Source=" & ThisWorkbookPath & "\wanquanbancsv"
connOpen strlj
Sql = "select from strlj where name='李四'"
'Database Connection
Dim cn As Workspace
Dim db As Database
Dim Rs As Recordset
Dim YOURPWD$, strSQL$, sContent$
'设置数据库
Set cn = DBEngineWorkspaces(0)
Set db = cnOpenDatabase(sDbPath, False, False, ";pwd=" & YOURPWD)
'打开数据库
strSQL = "Select From YourTable"
Set Rs = dbOpenRecordset(strSQL, , dbReadOnly)
代码复制到 报表 代码窗口,不要弄反了哦
Sub 获取数据()
x = WorksheetFunctionMatch([A1], Sheets("数据")Range("B:B"), 0)
arr = Sheets("数据")Range("d" & x & ":" & "h" & x)
[b4]Resize(1, 5) = arr
[b5] = Sheets("数据")Cells(x, "i")
End Sub
或
Sub 获取数据()
y = WorksheetFunctionCountIf(Sheets("数据")Range("B:B"), [a1])
If y = 0 Then
MsgBox "日期输入错误"
Exit Sub
End If
x = WorksheetFunctionMatch([a1], Sheets("数据")Range("B:B"), 0)
arr = Sheets("数据")Range("d" & x & ":" & "h" & x)
[b4]Resize(1, 5) = arr
[b5] = Sheets("数据")Cells(x, "i")
End Sub
以上就是关于VBA如何批量抓取数据全部的内容,包括:VBA如何批量抓取数据、EXCEL VBA怎么读写SQLSERVER 数据库、vba读取csv数据库中的数据,符合条件的加入到a列的excel表格中等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)