j4ymf

Well-known Member
Joined
Apr 28, 2003
Messages
740
Office Version
  1. 365
Platform
  1. Windows
hello I have found this code

how do I change the code to only change the selected cells to turn white
Cells.Interior.ColorIndex = 0

Cells(A12:AE39).Interior.ColorIndex = 0
I only want it to work on A12:AE39



Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
Application.ScreenUpdating = False
'Clear all cell colours
Cells.Interior.ColorIndex = 0
With Target
'Row and column highlightingfor the active cell
.EntireRow.Interior.ColorIndex = 19
.EntireColumn.Interior.ColorIndex = 19
End With
Application.ScreenUpdating = True
End Sub

Thank Jay
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
How about
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
Application.ScreenUpdating = False
'Clear all cell colours
Cells.Interior.ColorIndex = 0
With Target
'Row and column highlightingfor the active cell
.Interior.ColorIndex = 19
End With
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Or may be
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub
    Application.ScreenUpdating = False
    Cells.Interior.ColorIndex = 0
    If Not Intersect(Target, Range("A12:AE39")) Is Nothing Then
        Target.Interior.ColorIndex = 19
    End If
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Good Morning mohadin

thanks for the code

it works good but what im after is for the code to only change the background colour to white
Cells.Interior.ColorIndex = 0

my code works more like what im after but it changes the whole sheet and I only want it remove the interior colour between A12:AE39

Your just changes the colour that you have selected, I need it to change the whole row colour
does that make sense
thank you
 
Upvote 0
Like this?
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
[COLOR=#333333][FONT=Verdana]Cells.Interior.ColorIndex = 0[/FONT][/COLOR]
    If Target.Cells.Count > 1 Then Exit Sub
    Application.ScreenUpdating = False
    Cells.Interior.ColorIndex = 0
    If Not Intersect(Target, Range("A12:AE39")) Is Nothing Then
        Target.EntireRow.Interior.ColorIndex = 19
    End If
    Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0
hello mohadin

thank you but its still this line what not doing what I need
Cells.Interior.ColorIndex = 0
its chancing the whole sheet white and I only need it to change A12:AE39 white


Cells. range (A12:AE39 Interior.ColorIndex = 0 something like that!!!!!!!
 
Upvote 0
Aha
Code:
[COLOR=#333333]'Cells.Interior.ColorIndex = 0
[/COLOR]Range("A12:AE39").Interior.ColorIndex = 0
 
Last edited:
Upvote 0
Glad I can help
Thank you for feedback
Be happy
 
Upvote 0

Forum statistics

Threads
1,213,495
Messages
6,113,992
Members
448,538
Latest member
alex78

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