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
 
There is a solution:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

ActiveSheet.Unprotect Password:="yourPassword"

Range("A1:Z20").Interior.Pattern = xlSolid
ActiveCell.Interior.Pattern = xlSolid

ActiveSheet.Protect Password:="yourPassword", DrawingObjects:=True, Contents:=True, Scenarios:=True

End Sub
 
Upvote 0

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
On 2002-08-26 13:58, rikrak wrote:
There is a solution:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

ActiveSheet.Unprotect Password:="yourPassword"

Range("A1:Z20").Interior.Pattern = xlSolid
ActiveCell.Interior.Pattern = xlSolid

ActiveSheet.Protect Password:="yourPassword", DrawingObjects:=True, Contents:=True, Scenarios:=True

End Sub
Hi, you are great.It works but I get no colour in my cell.
Any idea?
 
Upvote 0
sorry Verluc, wrong lines. I was already trying something new. Here is what I wanted to send:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveSheet.Unprotect Password:="yourPassword"
Range("A1:Z20").Interior.Pattern = xlSolid
ActiveCell.Interior.Pattern = xlGray16
ActiveSheet.Protect Password:="yourPassword", DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub

It gives the active cell a pattern.
 
Upvote 0
On 2002-08-26 14:26, rikrak wrote:
sorry Verluc, wrong lines. I was already trying something new. Here is what I wanted to send:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveSheet.Unprotect Password:="yourPassword"
Range("A1:Z20").Interior.Pattern = xlSolid
ActiveCell.Interior.Pattern = xlGray16
ActiveSheet.Protect Password:="yourPassword", DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub

It gives the active cell a pattern.
Sorry,a last question.
Is it possible to make it in full red color?
Thanks
 
Upvote 0
I'm working on it.
Something with conditional format and a user defined function:
Function isActiveCell(cell As Range) As Boolean
isActiveCell = (ActiveCell.Address = cell.Address)
End Function

The problem is: how to force the conditional format to update.

Maybe tomorrow, it's bedtime now (24:00)
This message was edited by rikrak on 2002-08-26 14:59
 
Upvote 0
Hi verluc, try this.

1) Add following to a new or existing module:

Function isActiveCell(cell As Range) As Boolean
isActiveCell = (ActiveCell.Address = cell.Address)
End Function

2) In the worksheet select the area where the active cell has to be colored and
apply a conditional format:

formula is =isActiveCell('address of cell')

When you selected "A1:K100" type: formula is =isActiveCell(A1)
Select a fillcolor as pattern.

The result has to be:
A1: formula is =isActiveCell(A1)
B1: formula is =isActiveCell(B1)
...
K100: formula is =isActiveCell(K100)


3) Then add the last line of code into the worksheets "selectionChange" event:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
ActiveSheet.Range("A1:K100").Calculate
End Sub

(Range "A1:K100" is the same range as in 2)
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,583
Members
449,089
Latest member
Motoracer88

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