返回列表 上一主題 發帖

[發問] 自動判定成績合格及不合格,但不是依分數判定

如下

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
For M = 4 To 9
If Sheet1.Cells(M, 6).Font.ColorIndex = 3 Or Sheet1.Cells(M, 8).Font.ColorIndex = 3 Or Sheet1.Cells(M, 10).Font.ColorIndex = 3 Or Sheet1.Cells(M, 12).Font.ColorIndex = 3 Then
  Sheet1.Cells(M, 14) = "不合格"
  Else
  Sheet1.Cells(M, 14) = "合格"
End If
Next
End Sub
羅

TOP

+不合格自動秀紅色

Sub AA()
For M = 4 To 9
If Sheet1.Cells(M, 6).Font.ColorIndex = 3 Or Sheet1.Cells(M, 8).Font.ColorIndex = 3 Or Sheet1.Cells(M, 10).Font.ColorIndex = 3 Or Sheet1.Cells(M, 12).Font.ColorIndex = 3 Then
  Sheet1.Cells(M, 14) = "不合格"
  Sheet1.Cells(M, 14).Font.ColorIndex = 3
  Else
  Sheet1.Cells(M, 14) = "合格"
End If
Next

End Sub
羅

TOP

DEAR SIR
1將如下覆製到你有資料之SHEET1 "工作表中"就OK啦
  不要置於MODULE


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
For M = 4 To 9
If Sheet1.Cells(M, 6).Font.ColorIndex = 3 Or Sheet1.Cells(M, 8).Font.ColorIndex = 3 Or Sheet1.Cells(M, 10).Font.ColorIndex = 3 Or Sheet1.Cells(M, 12).Font.ColorIndex = 3 Then
  Sheet1.Cells(M, 14) = "不合格"
  Sheet1.Cells(M, 14).Font.ColorIndex = 3
  Else
  Sheet1.Cells(M, 14) = "合格"
  Sheet1.Cells(M, 14).Font.ColorIndex = 1
End If
Next
End Sub
羅

TOP

我公司檔傳檔案與圖片功能-不然早上傳ZIP檔給你拉
我看是板本問題
我將 SHEET1 改 工作表1 再試試
因它找不到 SHEET1 故秀出 BUG

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
For M = 4 To 9
If 工作表1.Cells(M, 6).Font.ColorIndex = 3 Or 工作表1.Cells(M, 8).Font.ColorIndex = 3 Or 工作表1.Cells(M, 10).Font.ColorIndex = 3 Or 工作表1.Cells(M, 12).Font.ColorIndex = 3 Then
  工作表1.Cells(M, 14) = "不合格"
  工作表1.Cells(M, 14).Font.ColorIndex = 3
  Else
  工作表1.Cells(M, 14) = "合格"
  工作表1.Cells(M, 14).Font.ColorIndex = 1
End If
Next
End Sub
羅

TOP

        靜思自在 : 稻穗結得越飽滿,越會往下垂,一個人越有成就,就要越有謙沖的胸襟。
返回列表 上一主題