Highlighting The Active Cell

P

Pelham

This is a Macro for 'Highlighting The Active Cell' that will change
the background color of the ActiveCell to yellow anytime you select a
new cell, either with the mouse or with the arrow keys.


Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object,
ByVal Target As Excel.Range)
Static OldRange As Range
On Error Resume Next
Target.Interior.ColorIndex = 6 ' yellow - change as needed
OldRange.Interior.ColorIndex = xlColorIndexNone
Set OldRange = Target

End Sub

The author says that if one wants to make the active cell appear in a
special color, use the following this code in the
Workbook_SheetSelectionChange event of the workbook. BUT, I am not good
with VBA or Macros yet so I do not know what he means ... How do I get
this Macro to work?
 
N

Norman Jones

Hi Pelham,

This is workbook event code and should be pasted into the workbook's
ThisWorkbook module *not* a standard module or a sheet module:

Right-click the Excel icon on the worksheet
(or the icon to the left of the File menu if your workbook is maximised)

Select 'View Code' from the menu and paste the code.

Alt-F11 to return to Excel.
 
P

Pelham

Hi Norman

Thanks so much!

I am a real rookie to VBA, so can you point me to a summary page of the
different VBA environments because I do not know the difference between
'workbook event code', 'standard module' or 'sheet module' etc.? All I
know about VBA is that you get to the VBE by pressing Alt+F11...!!!

Regards
Pelham
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top