Show cell selection in Excel when not in focus
It's really annoying that Excel (2003 and 2007) doesn't show what cell, row or column that is selected when the window is not in focus. I typically want to refer to the current cell or row while working in another application.
Is there any workaround or fix that will make the cell/row highlighted when not in focus? I know that you can copy a cell (Ctrl+C) but it's kind of tiresome to do that every time.
I think there is a work around but, it really depends on your situation!
You can create a macro which fires when the selection changes and it simply changes the background of each cell. When you 'leave' the cell it will reset the row's background value to white and then select the new row.
I added this to my Sheet1 in the Visual Basic window.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlColorIndexNone
ActiveCell.EntireRow.Interior.ColorIndex = 34
End Sub
This screen shot was taken while the application had lost focus.
This may be annoying but you could easily add a button which could toggle this feature on or off!
The negatives are (from top of my head : It will remove any current highlighting you have. So if you have highlighting on your page (cells coloured) then best not use this! Also, it will probably print with the highlighted rows!
Here is a modification of the code from @datatoo. It reads the previous values to prevent losing the current fill color. It also changes the text color to make it further stand out. I added it to the Excel sheet in the code editor (Alt-F11 from Excel).
Click here for information on making a worksheet change event.
'VBA code for Excel to show active cell in worksheet when worksheet is out of focus
Dim wasActive As String
Dim originalFillColor As String
Dim originalTextColor As String
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Set up colors on load
If wasActive = Empty Then
wasActive = "A1"
originalFillColor = Range(wasActive).Interior.Color
originalTextColor = Range(wasActive).Font.Color
End If
'Reset previous cell to original color values; If statement prevents removal of grid lines by using "0" for clear fill color when white
If originalFillColor = 16777215 Then
Range(wasActive).Interior.ColorIndex = "0"
Range(wasActive).Font.Color = originalTextColor
Else
Range(wasActive).Interior.Color = originalFillColor
Range(wasActive).Font.Color = originalTextColor
End If
'Set new colors and change active cell to highlighted colors (black fill with white text)
originalFillColor = ActiveCell.Interior.Color
originalTextColor = ActiveCell.Font.Color
wasActive = ActiveCell.Address
ActiveCell.Interior.ColorIndex = "1"
ActiveCell.Font.ColorIndex = "2"
End Sub
You can do something like this if you need to. Although it might be sheet specific
Dim wasActive As String
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If wasActive = Empty Then wasActive = "A1"
Range(wasActive).Interior.ColorIndex = "0"
ActiveCell.Interior.ColorIndex = "6"
wasActive = ActiveCell.Address
End Sub
This changes what is not active back to white, and changes the activecell to yellow. and still shows when the window is not active. Not sure this is the best way, but it works