macro colored cells

max_max

Board Regular
Joined
Jun 29, 2013
Messages
58
Good morning to all,
I hope to explain why my English .....
In the attached macro cell by inserting the letters are colored.
In the workbook there are colored stripes in yellow.
The problem is a letter canceling the cell must go yellow.
A greeting.
xam_xam
-----------------------------------------------------------------------------------------
Buongiorno a tutti,
spero di spiegarmi perchè il mio inglese.....
Nella macro allegata inserendo delle lettere la cella si colorano.
Nel workbook ci sono delle righe colorate in giallo.
Il problema è cancellando una lettera la cella deve tornare gialla.
Un saluto.
xam_xam

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range
Dim Rng2 As Range
Dim rCell As Range

Set Rng = Range("E4:AI39") '<<=== da CAMBIARE
Set Rng2 = Intersect(Rng, Target)

If Not Rng2 Is Nothing Then
For Each rCell In Rng2.Cells
With rCell
Select Case LCase(.Value)

Case Is = "a"
.Interior.ColorIndex = 3
Case Is = "b"
.Interior.ColorIndex = 6
Case Is = "c"
.Interior.ColorIndex = 8
Case Is = "d"
.Interior.ColorIndex = 4
Case Is = "e"
.Interior.ColorIndex = 5
Case Is = "f"
.Interior.ColorIndex = 28
Case Is = "g"
.Interior.ColorIndex = 14
Case Is = "h"
.Interior.ColorIndex = 12
Case Is = "i"
.Interior.ColorIndex = 33
Case Is = "j"
.Interior.ColorIndex = 18
Case Is = "k"
.Interior.ColorIndex = 41
Case Is = "l"
.Interior.ColorIndex = 42
Case Is = "m"
.Interior.ColorIndex = 12
Case Is = "n"
.Interior.ColorIndex = 11
Case Is = "o"
.Interior.ColorIndex = 6
Case Is = "p"
.Interior.ColorIndex = 28
Case Is = "q"
.Interior.ColorIndex = 35
Case Is = "r"
.Interior.ColorIndex = 49
Case Is = "s"
.Interior.ColorIndex = 16
Case Is = "t"
.Interior.ColorIndex = 15
Case Is = "u"
.Interior.ColorIndex = 45
Case Is = "v"
.Interior.ColorIndex = 52
Case Is = "w"
.Interior.ColorIndex = 54
Case Is = "x"
.Interior.ColorIndex = 50
Case Is = "y"
.Interior.ColorIndex = 49
Case Is = "z"
.Interior.ColorIndex = 5

Case Else
.Interior.ColorIndex = xlNone
End Select
End With
Next rCell
End If

 If Intersect(Target, Range("E4:AI39")) Is Nothing Then Exit Sub
  On Error Resume Next
   Application.EnableEvents = False
     Target = UCase(Target)
  Application.EnableEvents = True
  
End Sub
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hello,
I think this must be added to the macro:

if the line is equal and the cell is empty cell colors in yellow
if the line is odd and the cell is empty not color the cell

max_max
 
Upvote 0
,,
,,
,,
,,
,,

Case Is = "y"
.Interior.ColorIndex = 49
Case Is = "z"
.Interior.ColorIndex = 5

Case Else

.Interior.ColorIndex = 6 '<<< for row equal

.Interior.ColorIndex = 2 '<<< for row odd

,,
,,
,,
,,
 
Upvote 0
You can change the part in red, answer # 3
if even row colors in yellow
if odd row colors in white.
max_max
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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