- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
2#
發表於 2012-8-8 07:49
| 只看該作者
回復 1# fangsc - Sub Loaddata()
- Dim fcsty, bklogy As Integer
- Dim current_PL, current_cust_ID As String
- Dim search_PL, search_cust_ID As String
- Dim TC_Maxrow As Integer
- Dim Backlog_maxrow As Integer
- Dim start_col_in_TC As Integer
- Dim PL_index_col, CID_index_col As Integer
- '-----------------------------
- Dim Ar(1 To 2), xi As Integer, MyColorIndex As Integer
- '-----------------------------
- PL_index_col = 1
- CID_index_col = 3
- TC_Maxrow = 16
- Backlog_maxrow = 17
- start_col_in_TC = 58
- '----------------------------------------------
- Ar(1) = Array(0, 1, 3, 4, 5, 50, 51, 52, 53, 54)
- Ar(2) = Array(7, 8, 9, 10, 11, 14, 15, 16, 17, 18)
- MyColorIndex = 7 '底色 數值
- '----------------------------------------------
- Worksheets("TC").Activate
- For fcsty = 2 To TC_Maxrow
- search_PL = Worksheets("TC").Cells(fcsty, 16) '.FormulaR1C1
- search_cust_ID = Worksheets("TC").Cells(fcsty, 13) '.FormulaR1C1
- 'Worksheets("1").Select
- For bklogy = 2 To Backlog_maxrow
- current_PL = Worksheets("1").Cells(bklogy, PL_index_col) '.FormulaR1C1
- current_cust_ID = Worksheets("1").Cells(bklogy, CID_index_col) '.FormulaR1C1
- If Val(search_PL) = Val(current_PL) And Val(search_cust_ID) = Val(current_cust_ID) Then
- ' 條件符合時,將worksheet "1"的current_PL 及 current_cust_ID 加上底色,再執行以下寫入資料
- Worksheets("1").Cells(bklogy, PL_index_col).Interior.ColorIndex = MyColorIndex
- Worksheets("1").Cells(bklogy, CID_index_col).Interior.ColorIndex = MyColorIndex
- For xi = 0 To UBound(Ar(1))
- Worksheets("TC").Cells(fcsty, start_col_in_TC + Ar(1)(xi)) = Val(Worksheets("1").Cells(bklogy, Ar(2)(xi)))
- Next
- ' Worksheets("TC").Cells(fcsty, start_col_in_TC).FormulaR1C1 = Val(Worksheets("1").Cells(bklogy, 7).FormulaR1C1)
- ' Worksheets("TC").Cells(fcsty, start_col_in_TC + 1).FormulaR1C1 = Val(Worksheets("1").Cells(bklogy, 8).FormulaR1C1)
- ' Worksheets("TC").Cells(fcsty, start_col_in_TC + 3).FormulaR1C1 = Val(Worksheets("1").Cells(bklogy, 9).FormulaR1C1)
- ' Worksheets("TC").Cells(fcsty, start_col_in_TC + 4).FormulaR1C1 = Val(Worksheets("1").Cells(bklogy, 10).FormulaR1C1)
- ' Worksheets("TC").Cells(fcsty, start_col_in_TC + 5).FormulaR1C1 = Val(Worksheets("1").Cells(bklogy, 11).FormulaR1C1)
- ' Worksheets("TC").Cells(fcsty, start_col_in_TC + 50).FormulaR1C1 = Val(Worksheets("1").Cells(bklogy, 14).FormulaR1C1)
- ' Worksheets("TC").Cells(fcsty, start_col_in_TC + 51).FormulaR1C1 = Val(Worksheets("1").Cells(bklogy, 15).FormulaR1C1)
- ' Worksheets("TC").Cells(fcsty, start_col_in_TC + 52).FormulaR1C1 = Val(Worksheets("1").Cells(bklogy, 16).FormulaR1C1)
- ' Worksheets("TC").Cells(fcsty, start_col_in_TC + 53).FormulaR1C1 = Val(Worksheets("1").Cells(bklogy, 17).FormulaR1C1)
- ' Worksheets("TC").Cells(fcsty, start_col_in_TC + 54).FormulaR1C1 = Val(Worksheets("1").Cells(bklogy, 18).FormulaR1C1)
- End If
- Next 'bklogy
- Next 'fcsty
- End Sub
複製代碼 |
|