Bổ sung hightlight Cột (1 người xem)

Người dùng đang xem chủ đề này

Excel365

Thành viên tích cực
Tham gia
29/10/10
Bài viết
865
Được thích
127
Giới tính
Nam
[GPECODE=vb]Option Explicit
Private Sub CheckBox1_Click()
Cells.FormatConditions.Delete
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.FormatConditions.Delete
ActiveCell.EntireRow.FormatConditions.Add 2, , ActiveSheet.CheckBox1.Value
ActiveCell.EntireRow.FormatConditions(1).Interior.ColorIndex = 8
End Sub
[/GPECODE]

Code trên em tìm trên diễn đàn, lâu quá ko nhớ của ai.
Code trên hiện tại chỉ tô màu cho dòng khi checkbox được chọn. Nay em muốn cho nó tô màu luôn cột khi checkbox được chọn
P/s: Em có thể bổ sung thêm 2 dòng code
[GPECODE=vb]ActiveCell.EntireColumn.FormatConditions.Add 2, , ActiveSheet.CheckBox1.Value
ActiveCell.EntireColumn.FormatConditions(1).Interior.ColorIndex = 8
[/GPECODE]

đổi row thành column nhưng không được.
Rất mong được các anh chị giúp đỡ
 
PHP:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.FormatConditions.Delete
ActiveCell.EntireColumn.FormatConditions.Add 2, , ActiveSheet.CheckBox1.Value
ActiveCell.EntireColumn.FormatConditions(1).Interior.ColorIndex = 8
End Sub
Bạn chép thẳng vào sheet cầy thay đổi, mình thử được mà khi tích vào check bo x1
hình như bạn muốn cả dòng và cột đều có màu
PHP:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlNone
Rows(Target.Row).Interior.ColorIndex = 8
Columns(Target.Column).Interior.ColorIndex = 8
Target.Interior.ColorIndex = 3
End Sub
 
Lần chỉnh sửa cuối:
Upvote 0
PHP:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.FormatConditions.Delete
ActiveCell.EntireColumn.FormatConditions.Add 2, , ActiveSheet.CheckBox1.Value
ActiveCell.EntireColumn.FormatConditions(1).Interior.ColorIndex = 8
End Sub
Bạn chép thẳng vào sheet cầy thay đổi, mình thử được mà khi tích vào check bo x1
hình như bạn muốn cả dòng và cột đều có màu
PHP:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlNone
Rows(Target.Row).Interior.ColorIndex = 8
Columns(Target.Column).Interior.ColorIndex = 8
Target.Interior.ColorIndex = 3
End Sub
Code của bạn thì tô cả dòng và cột.
Nhưng tất cả màu của các cell mà tô trước đó đều bị xóa hết (Ví dụ: ô C1 trước đó tô màu vàng, khi checkbox được chọn thì màu nền bị xóa. Ý của mình muốn là khi check vào thì tất cả màu nền của các ô đã tô màu thì vẫn giữ nguyên không bị xóa.
 
Upvote 0
Code của bạn thì tô cả dòng và cột.
Nhưng tất cả màu của các cell mà tô trước đó đều bị xóa hết (Ví dụ: ô C1 trước đó tô màu vàng, khi checkbox được chọn thì màu nền bị xóa. Ý của mình muốn là khi check vào thì tất cả màu nền của các ô đã tô màu thì vẫn giữ nguyên không bị xóa.
PHP:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.FormatConditions.Delete
ActiveCell.EntireColumn.FormatConditions.Add 2, , ActiveSheet.CheckBox1.Value
ActiveCell.EntireColumn.FormatConditions(1).Interior.ColorIndex = 8
ActiveCell.EntireRow.FormatConditions.Add 2, , ActiveSheet.CheckBox1.Value
ActiveCell.EntireRow.FormatConditions(2).Interior.ColorIndex = 8
End Sub
Bạn thử lại nhé, có gì phản hồi lại sớm nhé, đợt này mình cũng hởi bận. Nếu ko giúp được bạn, bạn nhờ các anh chị khác nhé, Mình nhớ đề tài này trên GPE có nhiều, bạn vào tìm thử lại xem sao nhé
http://www.giaiphapexcel.com/forum/showthread.php?7671-Highlight-đơn-giản-(cải-tiến-mới)
Bạn có thể tham khảo link sau nhé
 
Upvote 0
PHP:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.FormatConditions.Delete
ActiveCell.EntireColumn.FormatConditions.Add 2, , ActiveSheet.CheckBox1.Value
ActiveCell.EntireColumn.FormatConditions(1).Interior.ColorIndex = 8
ActiveCell.EntireRow.FormatConditions.Add 2, , ActiveSheet.CheckBox1.Value
ActiveCell.EntireRow.FormatConditions(2).Interior.ColorIndex = 8
End Sub
Bạn thử lại nhé, có gì phản hồi lại sớm nhé, đợt này mình cũng hởi bận. Nếu ko giúp được bạn, bạn nhờ các anh chị khác nhé, Mình nhớ đề tài này trên GPE có nhiều, bạn vào tìm thử lại xem sao nhé
http://www.giaiphapexcel.com/forum/showthread.php?7671-Highlight-đơn-giản-(cải-tiến-mới)
Bạn có thể tham khảo link sau nhé
Đúng ý của mình rồi. Cám ơn bạn nhiều.
 
Upvote 0

Bài viết mới nhất

Back
Top Bottom