Solved

Highlighting the Active Cell in Excel

Posted on 2014-07-21
12
314 Views
Last Modified: 2014-07-21
EE Pros,

How do I change the condition for the active cell within Excel, to be highlighted?  Right now it's simply a bold box that shows up on the active cell.  Is there a way to either increase the boldness of the box on the active cell or give it some color?  It would make it easier to see in a large Worksheet.

Thank you,

B.
0
Comment
Question by:Bright01
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 26

Expert Comment

by:MacroShadow
Comment Utility
Try this macro, put it in the worksheet module:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Application.ScreenUpdating = False
    Cells.Interior.ColorIndex = 0          ' Clear the color of all the cells
    Target.Interior.ColorIndex = 8       ' Highlight the active cell
    Application.ScreenUpdating = True
End Sub

Open in new window

0
 
LVL 13

Expert Comment

by:duncanb7
Comment Utility
Do you need to do it on Excel Cell only  , please take a look the  MS manual for highlight and add/remove broder of the cell at this sites ?
http://office.microsoft.com/en-gb/excel-help/highlight-cells-HP001216435.aspx
http://office.microsoft.com/en-001/excel-help/apply-or-remove-cell-borders-on-a-worksheet-HP001216433.aspx

Duuncan
0
 

Author Comment

by:Bright01
Comment Utility
MicroShadow,

Almost works; but the ColorIndex = 0 changed all of my other colors in the WS.  I only need the highlighting on the cell I'm covering, then it needs to return to its original color.

Thank you,

B.
0
 

Author Comment

by:Bright01
Comment Utility
Duncan,

I'm using 2010....tried to use the Cell Styles but it didn't work.

B.
0
 
LVL 13

Expert Comment

by:duncanb7
Comment Utility
take a look at this for Excel Cell for cell style from MS manual
http://office.microsoft.com/en-001/excel-help/apply-create-or-remove-a-cell-style-HP001216732.aspx

Please let us know if want it on  VBA

Duncan
0
 
LVL 10

Expert Comment

by:Anthony Berenguel
Comment Utility
Is there a reason you can't use conditional formatting?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:Bright01
Comment Utility
I'm already using Conditional formatting for the content that is going into the cells.  I'm trying to highlight the cursor as I hover over the cells... so I can see them better.

B.
0
 

Author Comment

by:Bright01
Comment Utility
Duncan,

It's not that I want to change the cell style for a group of cells; it's that I want to highlight the cell I'm hovering over so I can see it better.......

B.
0
 
LVL 26

Expert Comment

by:MacroShadow
Comment Utility
Try this:
Public rngPrevious As Range
Public lngColor As Long

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Application.ScreenUpdating = False
    ' re-apply Interior.ColorIndex to previous cell
    rngPrevious.Interior.ColorIndex = lngColor
    ' Save original Interior.ColorIndex of curent cell
    lngColor = Target.Interior.ColorIndex
    Set rngPrevious = Target
    ' Highlight the active cell
    Target.Interior.ColorIndex = 8
    Application.ScreenUpdating = True
End Sub

Open in new window

0
 

Author Comment

by:Bright01
Comment Utility
I get a debug error on line:  rngPrevious.Interior.colorindex=lngcolor
0
 
LVL 26

Accepted Solution

by:
MacroShadow earned 500 total points
Comment Utility
That will only happen the first time, since the previous range wasn't set yet.

You can either precede that line with on error resume next or better yet check if rngPrevious isn't nothing.

Option Explicit

Public rngPrevious As Range
Public lngColor As Long

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Application.ScreenUpdating = False
    ' re-apply Interior.ColorIndex to previous cell
    If Not rngPrevious Is Nothing Then rngPrevious.Interior.ColorIndex = lngColor
    ' Save original Interior.ColorIndex of curent cell
    lngColor = Target.Interior.ColorIndex
    Set rngPrevious = Target
    ' Highlight the active cell
    Target.Interior.ColorIndex = 8
    Application.ScreenUpdating = True
End Sub

Open in new window

0
 

Author Closing Comment

by:Bright01
Comment Utility
Works great!  Much thanks.........


B.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now