Vì cần dùng code vì:Không dùng code được không bạn?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range
If Not Intersect(Target, [H7:H9]) Is Nothing Then
Application.EnableEvents = False
For Each Rng In Target
If Rng.Value = "?" Then
Rng.Offset(, -1).Interior.Color = 65535
Rng.Offset(, -1).Font.Color = -16776961
Else
Rng.Offset(, -1).Interior.Pattern = xlNone
Rng.Offset(, -1).Font.ColorIndex = xlAutomatic
End If
Next Rng
Application.EnableEvents = True
End If
End Sub
Cám ơn nhưng minh đã thử mà code chưa chạy được.Bạn sử dụng thử code này xem sao?
Mã:Private Sub Worksheet_Change(ByVal Target As Range) Dim Rng As Range If Not Intersect(Target, [H7:H9]) Is Nothing Then Application.EnableEvents = False For Each Rng In Target If Rng.Value = "?" Then Rng.Offset(, -1).Interior.Color = 65535 Rng.Offset(, -1).Font.Color = -16776961 Else Rng.Offset(, -1).Interior.Pattern = xlNone Rng.Offset(, -1).Font.ColorIndex = xlAutomatic End If Next Rng Application.EnableEvents = True End If End Sub
Code bài #4 hoạt động bình thường bạn nhé.Cám ơn nhưng minh đã thử mà code chưa chạy được.
Nếu bạn muốn dùng Button(nút) thì bạn tham khảo:Chào mọi người.
Cho mình hỏi code VBA để tự động bôi màu vàng và có chữ màu đỏ tại cột "Kết thúc" với điều kiện cột đánh giá là "dấu ?". Đính kèm file
Cám ơn.
PS: Thay vì dùng Conditional Formatting
Sub abc()
Dim Cll As Range
For Each Cll In Range("H7:H9")
If Cll.Value = "?" Then
Cll.Offset(, -1).Interior.ColorIndex = 6
Cll.Offset(, -1).Font.ColorIndex = 3
Else
Cll.Offset(, -1).Interior.ColorIndex = -4142
Cll.Offset(, -1).Font.ColorIndex = -4105
End If
Next Cll
End Sub