中燃料場報表生成器--出庫報表
阿新 • • 發佈:2018-11-10
從進銷存系統匯出的銷售明細表 一鍵 生成 出庫報表---V1.0版本
Sub CmdGroup1() ' ' CmdGroup1 巨集 ' 從進銷存到處的銷售明細表生成料場出庫報表 ' ' 判斷當前資料表是否為進銷存的銷售明細表 If Range("A1") <> "銷售明細表" Then MsgBox "當前資料表不是 《銷售明細表》 或者已經被修改,請確認!" End '結束程式的執行 End If ' 新建一個數據表,位於Sheet1後面 Sheets.Add After:=Sheets(1) ThisWorkbook.ActiveSheet.Name = "廣宗料場出庫明細" '合併後居中單元格 Range("A1:N1").Select With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom End With Selection.Merge Range("A1") = "材料出庫明細表" '填寫表頭 Range("A2") = "序號" Range("B2") = "出庫日期" Range("C2") = "紙質出庫單編號" Range("D2") = "採購網出庫單編號" Range("E2") = "物資編碼" Range("F2") = "物資名稱" Range("G2") = "單位" Range("H2") = "出庫數量" Range("I2") = "含稅單價" Range("J2") = "含稅金額" Range("K2") = "其它費用" Range("L2") = "領料單位" Range("M2") = "庫房名稱" Range("N2") = "備註" '設定表頭格式 Rows("1:1").RowHeight = 22.5 Range("A1:N1").Font.Size = 18 Range("A2:N2").Font.Size = 14 Range("A2:N2").Font.Bold = True With Range("A2:N2").Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorLight1 .TintAndShade = 0.499984740745262 .PatternTintAndShade = 0 End With With Range("A2:N2").Font .ThemeColor = xlThemeColorDark1 .TintAndShade = 0 End With '根據單元格的內容自動調整單元格大小 Cells.EntireColumn.AutoFit Cells.EntireRow.AutoFit '檢視銷售明細表一共記錄了多少行 Dim mItemCount As Integer mItemCount = Sheet1.UsedRange.Rows.Count '需要的資料為第10行~mItemCount-1行,複製到對應的表中 Sheet1.Range(Sheet1.Cells(10, 2), Sheet1.Cells(mItemCount - 1, 2)).Copy (ActiveSheet.Range("C3")) '單據編號 Sheet1.Range(Sheet1.Cells(10, 3), Sheet1.Cells(mItemCount - 1, 3)).Copy (ActiveSheet.Range("B3")) '單據日期 Sheet1.Range(Sheet1.Cells(10, 8), Sheet1.Cells(mItemCount - 1, 8)).Copy (ActiveSheet.Range("E3")) '物資編碼 Sheet1.Range(Sheet1.Cells(10, 9), Sheet1.Cells(mItemCount - 1, 9)).Copy (ActiveSheet.Range("F3")) '名稱 Sheet1.Range(Sheet1.Cells(10, 16), Sheet1.Cells(mItemCount - 1, 16)).Copy (ActiveSheet.Range("G3")) '單位 Sheet1.Range(Sheet1.Cells(10, 17), Sheet1.Cells(mItemCount - 1, 17)).Copy (ActiveSheet.Range("H3")) '數量 Sheet1.Range(Sheet1.Cells(10, 19), Sheet1.Cells(mItemCount - 1, 19)).Copy (ActiveSheet.Range("I3")) '單價 Sheet1.Range(Sheet1.Cells(10, 20), Sheet1.Cells(mItemCount - 1, 20)).Copy (ActiveSheet.Range("J3")) '金額 Sheet1.Range(Sheet1.Cells(10, 5), Sheet1.Cells(mItemCount - 1, 5)).Copy (ActiveSheet.Range("L3")) '來往單位 Sheet1.Range(Sheet1.Cells(10, 7), Sheet1.Cells(mItemCount - 1, 7)).Copy (ActiveSheet.Range("M3")) '庫房名稱 '填寫序號 Dim i As Integer For i = 3 To mItemCount - 8 Step 1 Cells(i, 1) = i - 2 Next i End Sub