返回列表 上一主題 發帖

[發問] 求救自動選色及填色~

試試看
  1. Sub 前景顏色代號_Change()
  2.    ActiveCell = Range("D2")
  3.    ActiveCell.Offset(, -1).Font.ColorIndex = ActiveCell
  4. End Sub

  5. Sub 背景顏色代號_Change()
  6.    ActiveCell = Range("E2")
  7.    ActiveCell.Offset(, -2).Interior.ColorIndex = ActiveCell
  8. End Sub

  9. Private Sub cmd填色_Click()
  10.    'ActiveCell 須在 欄10 和 欄16 之間
  11.    '按鈕 cmd填色 才有作用
  12.    col1 = ActiveCell.Column
  13.    If col1 < 10 Or col1 > 16 Then Exit Sub
  14.    
  15.    起點 = ActiveCell.Row
  16.    終點 = Cells(起點, 13).End(xlDown).Row
  17.    
  18.    'c欄 公司代表名稱 的總數
  19.    c代號總數 = [C3].End(xlDown).Row
  20.    
  21.    For mRow = 起點 To 終點
  22.       m代號 = UCase(Cells(mRow, 13))
  23.       For cRow = 3 To c代號總數
  24.          c代號 = Cells(cRow, 3)
  25.          If m代號 = c代號 Then
  26.             前景 = Cells(cRow, 4)
  27.             背景 = Cells(cRow, 5)
  28.             Cells(mRow, 10).Resize(, 7).Select
  29.             Selection.Interior.ColorIndex = 背景
  30.             Selection.Font.ColorIndex = 前景
  31.             Exit For
  32.          End If
  33.       Next
  34.    Next
  35. End Sub
複製代碼

TOP

        靜思自在 : 盡多少本份,就得多少本事。
返回列表 上一主題