Hi, I've been searching all day for answers to how I can pull this off. I have two tables of data where records match up when the tables are placed side by side. I have a code that currently highlights the entire row of the sheet for which cell I have active. Works great. But I also want to have the cell that is offset 13 cells to the right of my active cell to have a border around it. I believe the code needs to be declared as static because when I move to a new cell I want the border to disappear and reappear in the new active cell's relative 13 cells to the right. Here is my code below. I get an error saying "object required" when I try to run. PLEASE help. Thanks.
Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Static rr
Static cc
Static qq
If cc <> "" Then
With Columns(cc).Interior
.ColorIndex = xlNone
End With
With Rows(rr).Interior
.ColorIndex = xlNone
End With
With qq.Borders.LineStyle = Excel.XlLineStyle.xlLineStyleNone
End With
End If
r = Selection.Row
c = Selection.Column
rr = r
cc = c
q = ActiveCell.Offset(0, 13)
qq = q
With Rows(r).Interior
.ColorIndex = 35
.Pattern = xlAutomatic
With ActiveCell.Offset(0, 13).BorderAround(xlDouble)
End With
End With
End Sub
Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Static rr
Static cc
Static qq
If cc <> "" Then
With Columns(cc).Interior
.ColorIndex = xlNone
End With
With Rows(rr).Interior
.ColorIndex = xlNone
End With
With qq.Borders.LineStyle = Excel.XlLineStyle.xlLineStyleNone
End With
End If
r = Selection.Row
c = Selection.Column
rr = r
cc = c
q = ActiveCell.Offset(0, 13)
qq = q
With Rows(r).Interior
.ColorIndex = 35
.Pattern = xlAutomatic
With ActiveCell.Offset(0, 13).BorderAround(xlDouble)
End With
End With
End Sub