Changing coloue cell en text colour by clicking cell

H

hannes

Hi.

In a worksheet i want to change colour te red and the text colour to white
when a click one of the cell in the range O22:X44.
Is this possible?

Hannes
 
D

Don Guillett

Hi.

In a worksheet i want to change colour te red and the text colour to white
when a click one of the cell in the range O22:X44.
Is this possible?

Hannes

Right click sheet tab>view code copy this for a DOUBLE click

Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)

If Intersect(Target, Range("o22:x44")) _
Is Nothing Then Exit Sub

With Target
.Interior.ColorIndex = 46
.Font.ColorIndex = 2
End With
End Sub
 
H

hannes

Right click sheet tab>view code copy this for a DOUBLE click

Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)

If Intersect(Target, Range("o22:x44")) _
Is Nothing Then Exit Sub

With Target
.Interior.ColorIndex = 46
.Font.ColorIndex = 2
End With
End Sub

Thanks works perfect. Would it be possible to undo the changes by clicking
again?
 
D

Don Guillett

Hi.

In a worksheet i want to change colour te red and the text colour to white
when a click one of the cell in the range O22:X44.
Is this possible?

Hannes
Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)
If Intersect(Target, Range("o22:x44")) _
Is Nothing Then Exit Sub
With Target
If .Interior.ColorIndex = 46 Then
..Interior.ColorIndex = 0
..Font.ColorIndex = 1
Else
..Interior.ColorIndex = 46
..Font.ColorIndex = 2
End If
End With
End Sub


Hi.

In a worksheet i want to change colour te red and the text colour to white
when a click one of the cell in the range O22:X44.
Is this possible?

Hannes
 

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