Highlight active rows in a 2 or more table

Rayreloj10

New Member
Joined
Jun 26, 2023
Messages
15
Office Version
  1. 2019
Platform
  1. Windows
Hello!

I'm trying to highlight the active row in a table. I have multiple table in 1 sheet and I already formatted the sheet to highlight the row when selected. However, when selecting the row in a table, it also highlight the same row in all the tables. is there a way to only highlight the row in specific table.

Thank you in advance!
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
How did you format the sheet to highlight the row? Conditional formatting? VBA?
 
Upvote 0
Thank for the reply, yes, both. I just used simple code. newbie here.

in the conditional formatting

=ROW()=CELL("row")

VBA

VBA Code:
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)

Target.Calculate

End Sub

However, since the table are in the same rows, it also highlight the other rows in the other table.
 
Upvote 0
in the conditional formatting I used "Use a formula to determine which cells to format"

Excel Formula:
=ROW()=CELL("row")


VBA

VBA Code:
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)

Target.Calculate

End Sub

However, since the table are in the same rows, it also highlight the other rows in the other table.
 
Upvote 0
These are just suggestions. Trying to work towards a solution

So, a couple things. see this post about refreshing the conditional formatting

it uses this code

VBA Code:
On Error Resume Next
    ActiveSheet.EnableFormatConditionsCalculation = False
    ActiveSheet.EnableFormatConditionsCalculation = True
    On Error GoTo 0


Concerning restricting what gets highlighted. You need to specify the range that gets affected. In your conditional formatting (CF) range or "Applies to", you need to limit the range to each table you want to affect. I think you'll need to create a different CF for each table. The CF formula will also need to test which column the active cell is in. Something like below where the table columns begin in column 11 and ends on column 19.
=AND(Cell("Column")>10,Cell("Column")<20,=ROW()=CELL("row"))
 
Upvote 0
Thank you for your suggestion. upon researching I was able to come-up with a solution. As you said, I apply 3 different CF since I have 3 table. I just saw this code in the youtube and modify i,t since the highlight is visible to the table even though you click in the other table. I added the Else commad to disagage the CF to the table once you click to the other table. So as you can see I have 3 different CF which is assigned to each table.

Excel Formula:
=$A$1=ROW()
Excel Formula:
=$B$1=ROW()
Excel Formula:
=$C$1=ROW()

VBA Code:
Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("A7:F224")) Is Nothing Then
Range("A1").Value = Target.Row

Else: Range("A1") = Target.Row = False
 
   End If
  
    If Not Intersect(Target, Range("H7:M224")) Is Nothing Then
        Range("B1").Value = Target.Row
       
        Else: Range("B1") = Target.Row = False
       
        End If
       
        If Not Intersect(Target, Range("O7:T224")) Is Nothing Then
            Range("C1").Value = Target.Row

Else: Range("C1") = Target.Row = False

End If

End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,224,813
Messages
6,181,114
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top