COLOUR ACTIVE CELL

verluc

Well-known Member
Joined
Mar 1, 2002
Messages
1,451
Have somebody a macro,which can give a colour to the active cell?
Is this possible in "This workbook"
Many thanks
 
Hi another try / way

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Cells.Interior.ColorIndex = -4142
With Target.Interior
.ColorIndex = 5
End With
End Sub
 
Upvote 0

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
On 2002-08-26 05:10, Jack in the UK wrote:
Hi another try / way

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Cells.Interior.ColorIndex = -4142
With Target.Interior
.ColorIndex = 5
End With
End Sub
 
Upvote 0
On 2002-08-26 05:10, Jack in the UK wrote:
Hi another try / way

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Cells.Interior.ColorIndex = -4142
With Target.Interior
.ColorIndex = 5
End With






End Sub
Sorry Jack,but I get still an error
on the line :
Cells.Interior.ColorIndex = -4142
I can tell you that the sheet is protected with the cells who I need this colour are
not protected.Can this be a reason?
Thanks
 
Upvote 0
Hi Jack, the code works, but why do you loose the copy paste function?


Private Sub Worksheet_SelectionChange(ByVal target As Range)
If Intersect(Range("A1:IV65536"), Range(target(1).Address)) _
Is Nothing Then Exit Sub
Range("A1:IV65536").Interior.ColorIndex = xlNone
ActiveCell.Interior.Color = vbCyan
End Sub
 
Upvote 0
On 2002-08-26 06:43, dantb wrote:
Hi Jack, the code works, but why do you loose the copy paste function?


Private Sub Worksheet_SelectionChange(ByVal target As Range)
If Intersect(Range("A1:IV65536"), Range(target(1).Address)) _
Is Nothing Then Exit Sub
Range("A1:IV65536").Interior.ColorIndex = xlNone
ActiveCell.Interior.Color = vbCyan
End Sub
Sorry;but it works not to me.
See above,it is a protected sheet,with only the cells unlocked who I need this macro.
Thanks for a solution.
 
Upvote 0
On 2002-08-26 06:43, dantb wrote:
Hi Jack, the code works, but why do you loose the copy paste function?


Private Sub Worksheet_SelectionChange(ByVal target As Range)
If Intersect(Range("A1:IV65536"), Range(target(1).Address)) _
Is Nothing Then Exit Sub
Range("A1:IV65536").Interior.ColorIndex = xlNone
ActiveCell.Interior.Color = vbCyan
End Sub
Sorry;but it works not to me.
See above,it is a protected sheet,with only the cells unlocked who I need this macro and in that range there are already colour cells.
Thanks for a solution.
 
Upvote 0
On 2002-08-26 06:43, dantb wrote:
Hi Jack, the code works, but why do you loose the copy paste function?


Private Sub Worksheet_SelectionChange(ByVal target As Range)
If Intersect(Range("A1:IV65536"), Range(target(1).Address)) _
Is Nothing Then Exit Sub
Range("A1:IV65536").Interior.ColorIndex = xlNone
ActiveCell.Interior.Color = vbCyan
End Sub
Sorry;but it works not to me.
See above,it is a protected sheet,with only the cells unlocked who I need this macro and in that range there are already colour cells.
I have a macro that works perfect on a new sheet:
Sub Worksheet_SelectionChange(ByVal target As Range)
If Intersect(Range("A1:Z20"), Range(target(1).Address)) _
Is Nothing Then Exit Sub
Cells.Interior.ColorIndex = xlNone
ActiveCell.Interior.Color = vbCyan
End Sub

Thanks for a solution.
 
Upvote 0
Sorry;but it works not to me.
See above,it is a protected sheet,with only the cells unlocked who I need this macro and in that range there are already colour cells.
I have a macro that works perfect on a new sheet:
Sub Worksheet_SelectionChange(ByVal target As Range)
If Intersect(Range("A1:Z20"), Range(target(1).Address)) _
Is Nothing Then Exit Sub
Cells.Interior.ColorIndex = xlNone
ActiveCell.Interior.Color = vbCyan
End Sub

Thanks for a solution.

What about a pattern, so each cell can keep it's color?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Range("A1:Z20"), Range(Target(1).Address)) Is Nothing Then Exit Sub
Cells.Interior.Pattern = xlSolid
ActiveCell.Interior.Pattern = xlGray16
End Sub
 
Upvote 0
Sorry;but it works not to me.
See above,it is a protected sheet,with only the cells unlocked who I need this macro and in that range there are already colour cells.
I have a macro that works perfect on a new sheet:
Sub Worksheet_SelectionChange(ByVal target As Range)
If Intersect(Range("A1:Z20"), Range(target(1).Address)) _
Is Nothing Then Exit Sub
Cells.Interior.ColorIndex = xlNone
ActiveCell.Interior.Color = vbCyan
End Sub

Thanks for a solution.

What about a pattern, so each cell can keep it's color?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Range("A1:Z20"), Range(Target(1).Address)) Is Nothing Then Exit Sub
Cells.Interior.Pattern = xlSolid
ActiveCell.Interior.Pattern = xlGray16
End Sub
 
Upvote 0
On 2002-08-26 12:57, rikrak wrote:
Sorry;but it works not to me.
See above,it is a protected sheet,with only the cells unlocked who I need this macro and in that range there are already colour cells.
I have a macro that works perfect on a new sheet:
Sub Worksheet_SelectionChange(ByVal target As Range)
If Intersect(Range("A1:Z20"), Range(target(1).Address)) _
Is Nothing Then Exit Sub
Cells.Interior.ColorIndex = xlNone
ActiveCell.Interior.Color = vbCyan
End Sub

Thanks for a solution.

What about a pattern, so each cell can keep it's color?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Range("A1:Z20"), Range(Target(1).Address)) Is Nothing Then Exit Sub
Cells.Interior.Pattern = xlSolid
ActiveCell.Interior.Pattern = xlGray16
End Sub
O.K. but it works only when I remove my sheet protection.
I want to keep my sheet protection and only for those cells who are not protected.That is the difficulty.
Maybe there is not a solution?
Thanks for your time
 
Upvote 0

Forum statistics

Threads
1,215,523
Messages
6,125,318
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top