Highlight row in other sheets

mecerrato

Board Regular
Joined
Oct 5, 2015
Messages
174
Office Version
  1. 365
Platform
  1. Windows
Hi, I am using this great little piece of code that I got from this site to highlight the active row I am on:

But I tried applying to other sheets in the workbook and it does not work, the sheets I am trying to apply this to that are contained in the same workbook are "Credit_Pulls", "Applications", "Fundings", and "Current_Pipeline".

Can someone help me tweak to make it work?

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With ThisWorkbook.Names("HighlightRow")
.Name = "HighlightRow"
.RefersToR1C1 = "=" & ActiveCell.Row - 4
End With
'End Sub
With ThisWorkbook.Names("HighlightRowCredit")
.Name = "HighlightRowCredit"
.RefersToR1C1 = "=" & ActiveCell.Row
End With
End Sub
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hi mecerrato,

instead of Worksheet_SelectionChange behind the sheet you should use Workbook_SheetSelectionChange in ThisWorkbook. You should comment the code behind the sheet i where it is located by now and you would need to copy the CF to any sheet you indicated:
VBA Code:
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Select Case LCase(Sh.Name)
  Case "credit_pulls", "applications", "fundings", "current_pipeline"
    With ThisWorkbook.Names("HighlightRow")
      .Name = "HighlightRow"
      .RefersToR1C1 = "=" & ActiveCell.Row - 4
    End With
    With ThisWorkbook.Names("HighlightRowCredit")
      .Name = "HighlightRowCredit"
      .RefersToR1C1 = "=" & ActiveCell.Row
    End With
  Case Else
End Select
End Sub
Ciao,
Holger
 
Upvote 0
Hi HaHoBe,
I'm trying to accomplish the same fix in my workbook.
Can you explain what you mean by:
...Comment the code behind the sheet...?

Also, do the names of the worksheets need to be in all lower case because of the "Select Case LCase(Sh.Name)" in the VBA Code?
 
Last edited:
Upvote 0
Hi Snake Eyes,

if you place a routine in ThisWorkbook this will work for all worksheets so any single routine for teh same reason behind any sheet should be commented.

Yes, all names are lower case due to LCase being used.

HTH,
Holger.
 
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,542
Members
449,316
Latest member
sravya

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