Cell Colors as the cursor moves

rrowe

New Member
Joined
Feb 23, 2004
Messages
21
Is there a way to highlight ( in a color ) the cells as you move the cursor around in Excel? For instance, if you are in one cell, it would be in a color that you pick. When you move the cursor up, down, left, or right, the cell that you go to would then turn that color
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

verluc

Well-known Member
Joined
Mar 1, 2002
Messages
1,451
Try the following code :

Sub Worksheet_SelectionChange(ByVal target As Range)
If Intersect(Range("A1:Z20"), Range(target(1).Address)) _
Is Nothing Then Exit Sub
Cells.Interior.ColorIndex = xlNone
ActiveCell.Interior.Color = vbCyan
End Sub
 
Upvote 0

rrowe

New Member
Joined
Feb 23, 2004
Messages
21
Thanks for the quick reply. I don't know how to enter the code. Can you walk me thru, thanks!
 
Upvote 0

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
59,294
Office Version
  1. 365
Platform
  1. Windows
don't know how to enter the code. Can you walk me thru, thanks!
1. Right click the sheet name tab and choose "View Code".
2. Paste the code in the main right hand pane of the Visual Basic window that opens in step 1.
3. Close the VB window.

Notes:
1. The code is just to colour the cell if it is in the range A1:Z20, though you can change that if you want.
2. Be aware that if you have any cells in your worksheet coloured manually, that colour will be deleted by this code.
 
Upvote 0

rrowe

New Member
Joined
Feb 23, 2004
Messages
21
Thanks Verluc. It's great to have folks like you to be on standby for us rookies. Have a great day!!
 
Upvote 0

Forum statistics

Threads
1,191,057
Messages
5,984,408
Members
439,884
Latest member
BrownEyedGirl

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
Top