Tuy nhiên trong Excel lại không có tiện ích như vậy , và để làm được bạn cần có một đoạn mã nhúng trong đó , cách làm như sau :
Bấm chuột phải vào tên Sheet > View Code , sau đó bạn dán nội dung bên dưới
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Cells.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Rows(Selection.Row).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 5296274
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End Sub
Tương tự như vậy muốn đánh dấu cột như hình dưới , thì bạn làm tương tự như trên nhưng cần đoạn mã sau
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Cells.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Columns(Selection.Column).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 5296274
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End Sub