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
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

verluc

Well-known Member
Joined
Mar 1, 2002
Messages
1,451
On 2002-08-25 08:26, verluc wrote:
Have somebody a macro,which can give a colour to the active cell?
Is this possible in "This workbook"
Many thanks
I found the following macro,but it does'nt
work for me,because in the range I have protected cells.
Private Sub Worksheet_SelectionChange(ByVal target As Range)
If Intersect(Range("A1:Z20"), Range(target(1).Address)) _
Is Nothing Then Exit Sub
Range("A1:Z20").Interior.ColorIndex = xlNone
ActiveCell.Interior.Color = vbCyan
End Sub
 
Upvote 0

JayMenon

New Member
Joined
Aug 21, 2002
Messages
19
Hi !

The following code can do it !!
Sub colcell()
ActiveCell.Interior.Color = vbRed
End Sub

Thanks
 
Upvote 0

verluc

Well-known Member
Joined
Mar 1, 2002
Messages
1,451
On 2002-08-25 08:57, JayMenon wrote:
Hi !

The following code can do it !!
Sub colcell()
ActiveCell.Interior.Color = vbRed
End Sub

Thanks
Sorry,but it does'nt work for me.
 
Upvote 0

Jack in the UK

Well-known Member
Joined
Feb 16, 2002
Messages
3,215
This could be how and what protection you have XP has many more issues here,

Can you say what excel vesion and re above, but that codes OK for me also??

|||||||||||||||| Edit
No sorry nope that dont, niether of them??

I should turn off whats already running - teach me ill have a play.

_________________<embed width="200" height="50" src="http://homepage.a5.com/~kristy/misc/jack.swf">
This message was edited by Jack in the UK on 2002-08-25 09:59
 
Upvote 0

Jack in the UK

Well-known Member
Joined
Feb 16, 2002
Messages
3,215
Hi try this this one that was effecting my testing i use this : and it will work, DON not put in module but in he sheet required and will work

Private Sub Worksheet_SelectionChange(ByVal target As Range)
If Intersect(Range("A1:IV65536"), Range(target(1).Address)) _
Is Nothing Then Exit Sub
Cells.Interior.ColorIndex = xlNone
ActiveCell.Interior.Color = vbCyan
End Sub
 
Upvote 0

verluc

Well-known Member
Joined
Mar 1, 2002
Messages
1,451
On 2002-08-25 10:10, Jack in the UK wrote:
Hi try this this one that was effecting my testing i use this : and it will work, DON not put in module but in he sheet required and will work

Private Sub Worksheet_SelectionChange(ByVal target As Range)
If Intersect(Range("A1:IV65536"), Range(target(1).Address)) _
Is Nothing Then Exit Sub
Cells.Interior.ColorIndex = xlNone
ActiveCell.Interior.Color = vbCyan
End Sub
Hi Jack,
I get an error on the line:
Cells.Interior.ColorIndex = xlNone
Error 1004
Thanks for help.
 
Upvote 0

johny

Board Regular
Joined
Jul 15, 2002
Messages
69
IS THIS WHAT YOUR LOOKING FOR
ANY CELL YOU CHOOSE IS HIGHLIGHTED
OR DID YOU WANT TO LEAVE THE COLOR
I don't remember where I picked this macro up
but here is the example under Change

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range)
Static OldCell As Range

If Not OldCell Is Nothing Then
OldCell.Interior.ColorIndex = xlColorIndexNone
End If
Target.Interior.ColorIndex = 6
Set OldCell = Target
End Sub
 
Upvote 0

Jack in the UK

Well-known Member
Joined
Feb 16, 2002
Messages
3,215
Im useing that exact code now Windows XP Pro and Office XP Pro both FULL product and full installs???

No error

Try this version.. the code please put in the sheet not in its own module. [Microsoft Excel Object] Sheets as require.



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

No errors or debug, as tested. Should be OK
 
Upvote 0

verluc

Well-known Member
Joined
Mar 1, 2002
Messages
1,451
On 2002-08-25 10:47, Jack in the UK wrote:
Im useing that exact code now Windows XP Pro and Office XP Pro both FULL product and full installs???

No error

Try this version.. the code please put in the sheet not in its own module. [Microsoft Excel Object] Sheets as require.



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

No errors or debug, as tested. Should be OK
Thanks Jack,
Now it works.I need to use it in the range N7:AX25.
In that range there are cells who have already a colour.Those colours may not change.
Is this possible?
 
Upvote 0

Forum statistics

Threads
1,191,184
Messages
5,985,175
Members
439,945
Latest member
ospe

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
Top