Sub 執行()
Dim xR As Range, MH, Brr
[B2:X18].Interior.ColorIndex = 0
[G21:L21].ClearContents
Brr = [G21:L21]
For Each xR In Range("B" & Replace([C20], "-", ":X"))
MH = Application.Match(xR, [G20:L20], 0)
If IsNumeric(MH) Then
xR.Interior.ColorIndex = [G19].Cells(1, MH).Interior.ColorIndex
Brr(1, MH) = Brr(1, MH) + 1
End If
Next
[G21:L21] = Brr
End Sub作者: s7659109 時間: 2015-11-17 10:05
回復 13#s7659109
試試看:
我試過好像沒問題
還是舊的檔, 問題40-標示-1.rar, 但b21,c21 有改
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range, Cel As Range
Set Rng = Application.Union([B21:C21], [G20:L20])
If Intersect(Target, Rng) Is Nothing Then Exit Sub
If Not Intersect(Target, [B21:C21]) Is Nothing Then
[B2:X18].Interior.ColorIndex = xlNone
[G20:L20].Interior.ColorIndex = xlNone
[G21:L21] = ""
If [B21] > [C21] Then
MsgBox "注意:" & Chr(10) & "啟始列的值 不可以大於 終止列的值", vbCritical
Exit Sub
End If
End If
Set Rng = Range("B" & [B21] & ":X" & [C21] & "")
If Not Intersect(Target, [G20:L20]) Is Nothing Then
[B2:X18].Interior.ColorIndex = xlNone
[G20:L20].Interior.ColorIndex = xlNone
[G21:L21] = ""
On Error Resume Next
Set Cel = Rng.Find(What:=Target, LookIn:=xlFormulas, LookAt:=xlWhole)
If Cel Is Nothing Then
MsgBox "注意:" & Chr(10) & "資料輸入錯誤!!", vbCritical
Exit Sub
End If
[N21] = "= COUNTA(G20:L20)"
If [N21] <> 6 Then Exit Sub
[N20] = "=SUMPRODUCT((G20:L20<>"""")/COUNTIF(G20:L20,G20:L20&""""))"
If [N20] < 6 Then
MsgBox "注意:" & Chr(10) & "輸入區資料重覆!!", vbCritical
Exit Sub
End If
End If
開始統計
End Sub作者: s7659109 時間: 2015-11-19 07:53