|
- Sub Opiona()
- 'On Error Resume Next '// 发生错误,自动执行下一句,就是忽略错误
- Application.ScreenUpdating = False '//关闭屏幕刷新
- Application.DisplayAlerts = False '//关闭系统提示
- t = Timer '//开始时间
-
- Str_coon = "HDR=NO;IMEX=1';Data Source =" & ThisWorkbook.FullName '//OFFICE2003,2007 通用
- Str进出 = "出"
- Set SH0 = Sheets("总表" & Str进出)
- SH0.Range("A4:S65536").ClearContents
- For I = 1 To 12
- StrSQL = "SELECT F1 AS 日期,F2 AS 码单号,F3 AS 品名,F4 AS 数量,F5 AS 合计"
- StrSQL = StrSQL & ",F6 AS 杉木原木,F7 AS 杉木小径,F8 AS 杉木等外"
- StrSQL = StrSQL & ",F9 AS 松木原木,F10 AS 松木小径,F11 AS 松木等外"
- StrSQL = StrSQL & ",F12 AS 杂木原木,F13 AS 杂木小径,F14 AS 杂木等外"
- StrSQL = StrSQL & ",F15 AS 薪材松木,F16 AS 薪材杂木,F17 AS 锯材松锯材,F18 AS 锯材杂锯材"
- StrSQL = StrSQL & "," & Format(I, "00") & " AS 月份"
- StrSQL = StrSQL & " FROM [" & Str进出 & Format(I, "00") & "月$A6:R] WHERE 1=1"
- StrSQL = StrSQL & " AND INSTR(F1,'合计')=0"
- StrSQL = StrSQL & " AND INSTR(F1,'累计')=0"
- ' StrSQL = StrSQL & " AND INSTR(F1,'库存')=0"
- StrSQL = StrSQL & " AND F4>0"
- IROW = SH0.Range("A65536").End(3).Row + 1
- If IROW < 4 Then IROW = 4
- SQLARR = GET_SQL_To_Arr(StrSQL, Str_coon, False)
- SH0.Range("A" & IROW).Resize(UBound(SQLARR, 1) + 1, UBound(SQLARR, 2) + 1) = SQLARR '//(0 TO X)的数组行列都要+1,(1 TO X) 的不要
- Next I
- Str进出 = "进"
- Set SH0 = Sheets("总表" & Str进出)
- SH0.Range("A4:S65536").ClearContents
- For I = 1 To 12
-
- StrSQL = "SELECT F1 AS 日期"
- StrSQL = StrSQL & ",F17 AS 码单号"
- StrSQL = StrSQL & ",F2 AS 合计"
- StrSQL = StrSQL & ",F3 AS 杉木原木"
- StrSQL = StrSQL & ",F4 AS 杉木小径"
- StrSQL = StrSQL & ",F5 AS 杉木等外"
- StrSQL = StrSQL & ",F6 AS 松木原木"
- StrSQL = StrSQL & ",F7 AS 松木小径"
- StrSQL = StrSQL & ",F8 AS 松木等外"
- StrSQL = StrSQL & ",F9 AS 杂木原木"
- StrSQL = StrSQL & ",F10 AS 杂木小径"
- StrSQL = StrSQL & ",F11 AS 杂木等外"
- StrSQL = StrSQL & ",F12 AS 薪材松木"
- StrSQL = StrSQL & ",F13 AS 薪材杂木"
- StrSQL = StrSQL & ",F14 AS 锯材松锯材"
- StrSQL = StrSQL & ",F15 AS 锯材杂锯材"
- StrSQL = StrSQL & "," & Format(I, "00") & " AS 月份"
- StrSQL = StrSQL & " FROM [" & Str进出 & Format(I, "00") & "月$A6:Q] WHERE 1=1"
- StrSQL = StrSQL & " AND INSTR(F1,'合计')=0"
- StrSQL = StrSQL & " AND INSTR(F1,'累计')=0"
- ' StrSQL = StrSQL & " AND INSTR(F1,'库存')=0"
- IROW = SH0.Range("A65536").End(3).Row + 1
- If IROW < 4 Then IROW = 4
- SQLARR = GET_SQL_To_Arr(StrSQL, Str_coon, False)
- SH0.Range("A" & IROW).Resize(UBound(SQLARR, 1) + 1, UBound(SQLARR, 2) + 1) = SQLARR '//(0 TO X)的数组行列都要+1,(1 TO X) 的不要
- Next I
-
- Application.ScreenUpdating = True '//恢复屏幕刷新
- Application.DisplayAlerts = True '//恢复系统提示
- MsgBox "一共用时:" & Format(Timer - t, "#0.0000") & " 秒", , "北极狐提示!!" '//提示所用时间
- End Sub
复制代码 |
|