#1
|
|||
|
|||
VBA combination drop down macro - changing colors
Hello,
My first post on here and looking for some help! I have two different drop downs in a table in word. I have it set up so when certain items are selected, the cells turn to a certain color. I want to have it so when certain combinations are selected, both cells turn to a specific color. For example; when Manageable and Unlikely are selected, I want both cells to be Lime colored. When Major and Likely are selected, I want both cells to be Red. Below is my code. I am completely stuck. This is currently working with only changing one cell at a time. Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) If ContentControl.Title = "Impact" Then With ContentControl.Range Select Case .Text Case "Manageable" .Cells(1).Shading.BackgroundPatternColor = wdColorLime Case "Moderate" .Cells(1).Shading.BackgroundPatternColor = wdColorYellow Case "Major" .Cells(1).Shading.BackgroundPatternColor = wdColorRed Case "Catastrophic" .Cells(1).Shading.BackgroundPatternColor = wdColorRed End Select End With End If If ContentControl.Title = "Likelihood" Then With ContentControl.Range Select Case .Text Case "Unlikely" .Cells(1).Shading.BackgroundPatternColor = wdColorLime Case "Possible" .Cells(1).Shading.BackgroundPatternColor = wdColorYellow Case "Likely" .Cells(1).Shading.BackgroundPatternColor = wdColorYellow Case "Almost Certain" .Cells(1).Shading.BackgroundPatternColor = wdColorRed End Select End With End If End Sub |
#2
|
|||
|
|||
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) Dim oCC1 As ContentControl, oCC2 As ContentControl If ContentControl.Title = "Impact" Or ContentControl.Title = "Likelihood" Then Set oCC1 = ActiveDocument.SelectContentControlsByTitle("Impact").Item(1) Set oCC2 = ActiveDocument.SelectContentControlsByTitle("Likelihood").Item(1) Select Case True Case oCC1.Range.Text = "Manageable" And oCC2.Range.Text = "Unlikely" oCC1.Range.Cells(1).Shading.BackgroundPatternColor = wdColorLime oCC2.Range.Cells(1).Shading.BackgroundPatternColor = wdColorLime Case Else oCC1.Range.Cells(1).Shading.BackgroundPatternColor = wdColorAutomatic oCC2.Range.Cells(1).Shading.BackgroundPatternColor = wdColorAutomatic End Select End If End Sub |
#3
|
|||
|
|||
Thank you so much gmaxey! It worked!
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
changing drop down menus in a mail-merged document | Taras49 | Word | 4 | 02-27-2017 11:30 AM |
Help with drop down menu changing Italic font when unlinked | brent chadwick | Word VBA | 3 | 11-24-2015 12:48 PM |
Changing dropdown list colors in office 2010 forms | Barry Bolton | Word | 1 | 02-19-2014 03:26 PM |
Help with macro to set font colors | Jennifer Murphy | Word VBA | 1 | 09-29-2013 09:57 PM |
Changing the placeholder text for drop down boxes | DeadBatteries | Word | 1 | 08-24-2012 09:09 AM |