|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 fengyangbo 于 2024-8-25 21:32 编辑
Set sh1 = Sheets("表单")
Set SH2 = Sheets("BOm")
Set sh3 = Sheets("配料清单")
sh3.Range("A6:c65536").ClearContents
sh3.Range("E3") = sh1.Range("q3")
sh3.Range("g3") = sh1.Range("h3")
sh3.Range("e4") = sh1.Range("c3")
sh3.Range("g4") = Application.Sum(sh1.Range("H5:H112")) / 2
Str_coon = "Provider=Microsoft.JET.OLEDB.4.0;Extended Properties='Excel 8.0;HDR=yes';Data Source=" & ThisWorkbook.FullName '//OFFICE2003
StrSQL = "SELECT B.配件编码,SUM(B.单只数量*A.[发货数(只)]) AS 数量 FROM ("
StrSQL = StrSQL & "SELECT * FROM [" & sh1.Name & "$B4:H] WHERE LEN(aodi号)>0"
StrSQL = StrSQL & ") AS A LEFT JOIN ("
StrSQL = StrSQL & "SELECT 配件编码,aodi号,单只数量 FROM [" & SH2.Name & "$] WHERE LEN(aodi号)>0"
StrSQL = StrSQL & ") AS B ON A.aodi号=B.aodi号"
StrSQL = StrSQL & " GROUP BY B.配件编码"
StrSQL = StrSQL & " ORDER BY B.配件编码"
SQLARR = GET_SQL_To_Arr(StrSQL, Str_coon, False)
sh3.Range("B6").Resize(LBound(SQLARR, 1) + 1, LBound(SQLARR, 2) + 1) = SQLARR ‘这里过不去了
For IROW = 6 To sh3.Range("B65536").End(3).Row
sh3.Cells(IROW, 1) = IROW - 5
Next IROW
sh3.Select
Application.ScreenUpdating = True '//恢复屏幕刷新
Application.DisplayAlerts = True '//恢复系统提示
在原2010版 上运行正常,但是换到2016就出现下标越界9,看了书上562页,但是没有搞懂。
请各位大神帮忙看看哪里出错了。先谢谢了。
|
|