返回列表 上一主題 發帖

[發問] 將多筆同單號的資料放入一個儲存格內,資料不重複及多條件加總

本帖最後由 c_c_lai 於 2013-8-18 09:22 編輯

回復 15# yliu
將你目前的 Report 予以稍稍整理一下,方便閱讀及縮小(精簡)程式碼。
供你參考與應用:
  1. Private Sub ComboBox1_Change()
  2.     Dim d As Object, j As Integer
  3.    
  4.     Sheets("report").Unprotect ("789456123")
  5.    ClearFlds
複製代碼
  1.         If dic.Count = 0 Then
  2.             MsgBox "沒有議價資料"
  3.             ClearFlds
  4.            Exit Sub
  5.         End If
複製代碼
  1. Sub ClearFlds()
  2.     With Sheets("report")
  3.         ' .Cells(5, 2) = ""
  4.         ' .Cells(6, 2) = ""
  5.         ' .Cells(7, 2) = ""
  6.         ' .Cells(8, 2) = ""
  7.         ' .Cells(9, 2) = ""
  8.         ' .Cells(10, 2) = ""
  9.         ' .Cells(13, 2) = ""
  10.         ' .Cells(14, 2) = ""
  11.         ' .Cells(15, 2) = ""
  12.         ' .Cells(16, 2) = ""
  13.         ' .Cells(18, 2) = ""
  14.         ' .Cells(19, 2) = ""
  15.         ' .Cells(20, 2) = ""
  16.         ' .Cells(21, 2) = ""
  17.         .Range("B5:B10") = ""
  18.         .Range("B13:B21") = ""
  19.    
  20.         ' .Cells(13, 3) = ""
  21.         ' .Cells(14, 3) = ""
  22.         ' .Cells(15, 3) = ""
  23.         ' .Cells(16, 3) = ""
  24.         .Range("C13:C16") = ""
  25.    
  26.         .Cells(5, 4) = ""
  27.         ' .Cells(9, 4) = ""
  28.         ' .Cells(10, 4) = ""
  29.         .Range("D9:D10") = ""
  30.    
  31.         ' .Cells(13, 4) = ""
  32.         ' .Cells(14, 4) = ""
  33.         ' .Cells(15, 4) = ""
  34.         ' .Cells(16, 4) = ""
  35.         ' .Cells(20, 4) = ""
  36.         ' .Cells(21, 4) = ""
  37.         .Range("D13:D21") = ""
  38.     End With
  39. End Sub
複製代碼
ReportB.rar (23.43 KB)

TOP

        靜思自在 : 慈悲沒有敵人,智慧不起煩惱。
返回列表 上一主題