colorful cells

  • Thread starter Thread starter hakan
  • Start date Start date
H

hakan

I have seen a file, active cell becomes colorful and
everytime cursor moves to another cell new cell becomes
colorful. I could not figure it out from conditional
formation please help.
Thanking in advance
 
right click sheet tab>view code>insert this

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
On Error GoTo endit
Cells.Interior.ColorIndex = 0
ActiveCell.Interior.ColorIndex = 6
endit:
Application.EnableEvents = True
End Sub
 
Here is a slight alternative that doesn't wipe out any other coloured cells

Dim oldCell As Range
Dim oldCol As Long

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
On Error GoTo endit
If Not oldCell Is Nothing Then
oldCell.Interior.ColorIndex = oldCol
End If
Set oldCell = Target
With Target
oldCol = .Interior.ColorIndex
.Interior.ColorIndex = 6
End With
endit:
Application.EnableEvents = True
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Good one Bob,
I can use that too,
Thanks,
Alan.
Bob Phillips said:
Here is a slight alternative that doesn't wipe out any other coloured cells

Dim oldCell As Range
Dim oldCol As Long

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
On Error GoTo endit
If Not oldCell Is Nothing Then
oldCell.Interior.ColorIndex = oldCol
End If
Set oldCell = Target
With Target
oldCol = .Interior.ColorIndex
.Interior.ColorIndex = 6
End With
endit:
Application.EnableEvents = True
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Hi Alan,
As much as I like Event macros, there is price with
all macros in that they wipe out the undo stack so
you cannot use Ctrl+Z to undo anything earlier.
An Event macro keeps you from using undo
at on that worksheet.

Unfortunately there is not accessibility feature
that I know of that addresses making the active
cell more visible, if really needed.

Since undo is such an important feature in
many application software I'd try to make sure
that the feature is worth more to me than the
ability to undo something.

When you select a cell the column letter and the
row letter are changed in color and I think Excel
2000 improves the distinction of selected areas
compared to previous versions.

Another event macro that is rather popular here
for that purpose is Chip Pearson's Rowliner
http://www.cpearson.com/excel/rowliner.htm

If you know you need a macro the excel.programming
group is the better group then we assume you know
about such things as installation and loss of undo stack.

The newsgroup He
 
Thanks David,
Food for thought indeed,
Regards,
Alan.
David McRitchie said:
Hi Alan,
As much as I like Event macros, there is price with
all macros in that they wipe out the undo stack so
you cannot use Ctrl+Z to undo anything earlier.
An Event macro keeps you from using undo
at on that worksheet.

Unfortunately there is not accessibility feature
that I know of that addresses making the active
cell more visible, if really needed.

Since undo is such an important feature in
many application software I'd try to make sure
that the feature is worth more to me than the
ability to undo something.

When you select a cell the column letter and the
row letter are changed in color and I think Excel
2000 improves the distinction of selected areas
compared to previous versions.

Another event macro that is rather popular here
for that purpose is Chip Pearson's Rowliner
http://www.cpearson.com/excel/rowliner.htm

If you know you need a macro the excel.programming
group is the better group then we assume you know
about such things as installation and loss of undo stack.

The newsgroup He


Alan said:
Good one Bob [Phillips],
I can use that too,
 

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