Highlighting Selected Cells

Excel9925

New Member
Joined
Dec 24, 2010
Messages
2
I never liked the black print on very light gray interior for selected cells that is the default for Excel 2007.

I found a cool procedure in an old post on this site to change the color of cells selected in a worksheet. I'd love to make this the default for all sheets and workbooks. Is there any way to do this?

(I had done one change (involving the Registry) that I found in a book I have, which changes the highlighted cells to an interior color of black with white text, but it's too dark to read easily. I would have really loved an interior color of medium gray with black type, but the only results I could get by altering the numbers in the Registry version was the Excel defaults or the white text on black interior.)

The code that works for a worksheet is below.


Public OldRng As Range

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not OldRng Is Nothing Then
OldRng.Interior.ColorIndex = xlNone
End If
Target.Interior.ColorIndex = 6
Set OldRng = Target
End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
welcome on board.

put it in workbook code and not worksheet

Public OldRng As Range
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
If Not OldRng Is Nothing Then
OldRng.Interior.ColorIndex = xlNone
End If
Target.Interior.ColorIndex = 6
Set OldRng = Target
End Sub

hope this will help.
 
Upvote 0
Thanks for the reply. That worked for all sheets in a workbook. Now, is there a way to make it work for any workbook that is opened?
 
Upvote 0

Forum statistics

Threads
1,214,821
Messages
6,121,759
Members
449,048
Latest member
excelknuckles

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