View Single Post
 
Old 12-11-2013, 09:11 PM
oalrashdan oalrashdan is offline Windows XP Office 2007
Novice
 
Join Date: Dec 2013
Posts: 1
oalrashdan is on a distinguished road
Default (Excel 2007) Need help with colour change when condition met in drop down list

Hi all, first post here your help is highly appreciated.

I Have Vba drop down list with 9 words and you can choose multiple choices. What i want to do is for each word chosen to change the colour of the whole row. I have tried many ways but its not working with me.

The code below I use for multiple choices.

PHP Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim rngDV As Range
Dim oldVal 
As String
Dim newVal 
As String
If Target.Count 1 Then GoTo exitHandler

On Error Resume Next
Set rngDV 
Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo exitHandler

If rngDV Is Nothing Then GoTo exitHandler

If Intersect(TargetrngDVIs Nothing Then
   
'do nothing
Else
  Application.EnableEvents = False
  newVal = Target.Value
  Application.Undo
  oldVal = Target.Value
  Target.Value = newVal
  If Target.Column = 6 Then
    If oldVal = "" Then
      '
do nothing
      
Else
      If 
newVal "" Then
      
'do nothing
      Else
      Target.Value = oldVal _
        & ", " & newVal
'      
NOTEyou can use a line break,
'      instead of a comma
'      
Target.Value oldVal _
'        & Chr(10) & newVal
      End If
    End If
  End If
End If

exitHandler:
  Application.EnableEvents = True
End Sub 
Reply With Quote