函数计算机代码,求excel 函数 程序源代码 是vba的代码
Sub lqxs()Dim conn, Sql$, Arr, i&, d, Arr1, aaSet d = CreateObject("Scripting.Dictionary")On Error GoTo 100Set conn = CreateObject("adodb.connection")conn.Open "provider=microsoft.jet.oledb.4.0;ex
Sub lqxs()
Dim conn, Sql$, Arr, i&, d, Arr1, aa
Set d = CreateObject("Scripting.Dictionary")
On Error GoTo 100
Set conn = CreateObject("adodb.connection")
conn.Open "provider=microsoft.jet.oledb.4.0;extended properties=excel 8.0;data source=" & ThisWorkbook.Path & "\总库存.xls"
Sql = "select * from [kucun$]"
Sheet1.Activate
Arr = conn.Execute(Sql).getrows
For i = 0 To UBound(Arr, 2)
If Not d.exists(Arr(1, i)) Then
d(Arr(1, i)) = Arr(2, i) & "," & Arr(7, i) & "," & Arr(8, i) & "," & Arr(11, i)
End If
Next
Arr1 = [a1].CurrentRegion
For i = 2 To UBound(Arr1)
If d.exists(Arr1(i, 2)) Then
aa = Split(d(Arr1(i, 2)), ",")
Cells(i, 3) = aa(0)
Cells(i, 5) = aa(1)
Cells(i, 6) = aa(2)
Cells(i, 7) = aa(3)
End If
Next
GoTo 200
100:
MsgBox "没有此数据!"
200:
[a2].Select
conn.Close
Set conn = Nothing
End Sub
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)