That is the macro that corresponds to your statement, I understand (there are no lines A through X, are the columns that are identified by letters?).
Make a right click on the sheet tab where you want the macro to run and then click on "View Code". Then copy and paste the following code:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim intLine As Integer
'No. current line:
intLine = ActiveCell.Row
'If the line number clicked is less than or equal to 22 (line "X")
If intLine <= 22 Then
'Action on the value of the first cell of the current line:
Select Case Cells(intLine, 1)
Case "Jack" 'If the cell value is equal to Jack:
Cells(1, 3).Interior.Color = vbRed 'cell A3 in red
Cells(1, 5).Interior.Color = vbRed 'cell A5 in red
Case "Paul" 'If the cell value is equal to Paul:
Cells(1, 2).Interior.Color = vbGreen 'cell A2 in green
Cells(1, 4).Interior.Color = vbGreen 'cell A4 in green
Case "" 'If the cell is empty
Cells(1, 3).Interior.ColorIndex = xlNone 'cell A3 transparent
Cells(1, 5).Interior.ColorIndex = xlNone 'cell A5 transparent
End Select
End If
End Sub
Bookmarks