Cell interior color

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do change a cell's interior color when a first gets the focus and when it
losses the focus. In other words when I first click on a cell is changes
color and when I click elsewhere it change color.

TIA
johnb
 
Whenever a cell is Active, it is empahsized. In XL97 it simply puts a heavy
border around the cell, in newer versions it may enphasize by some other
method. When you "click-off" that cell to another cell, the emphasis
follows. If you wish to permanently color a cell, then highlight it and do
Right-click > FormatCells > Patterns > and choose a color..........or, you
can also color cells by using the ConditionalFormat feature...........

hth
Vaya con Dios,
Chuck, CABGx3
 
Hi John


One way

You can use Format>Conditional Formatting>use dropdown for Formula Is>
=(ROW()=CELL("Row"))
or
=(COLUMN() = CELL("Col"))
set Format to whatever you wish

In order for this to operate, it will need a sheet event to force a
Calculate, otherwise the changes won't occur

Right click on the sheet tab and choose View Code
Copy and Paste the code blow into the sheet code area. Change Sheet
number to whatever Sheet you are using, I happened to be using Sheet3

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Sheet3.Calculate
End Sub
 
Thanks Roger

Will try that.

Roger Govier said:
Hi John


One way

You can use Format>Conditional Formatting>use dropdown for Formula Is>
=(ROW()=CELL("Row"))
or
=(COLUMN() = CELL("Col"))
set Format to whatever you wish

In order for this to operate, it will need a sheet event to force a
Calculate, otherwise the changes won't occur

Right click on the sheet tab and choose View Code
Copy and Paste the code blow into the sheet code area. Change Sheet
number to whatever Sheet you are using, I happened to be using Sheet3

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Sheet3.Calculate
End Sub
 
John

You could download Chip Pearson's ROWLINER add-in from

http://www.cpearson.com/excel/RowLiner.htm

Or use event code

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Static OldCell As Range
If Not OldCell Is Nothing Then
OldCell.Interior.ColorIndex = xlColorIndexNone
End If
Target.Interior.ColorIndex = 3
Set OldCell = Target
End Sub

Note: this is sheet event code. Right-click on the sheet tab and "View Code".

Copy/paste into that module.

If not what you're looking for, post back.


Gord Dibben MS Excel MVP

How do change a cell's interior color when a first gets the focus and when it
losses the focus. In other words when I first click on a cell is changes
color and when I click elsewhere it change color.

TIA
johnb

Gord Dibben MS Excel MVP
 

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

Back
Top