Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-27-2017, 06:52 AM
runke1tj runke1tj is offline VBA combination drop down macro - changing colors Windows 7 64bit VBA combination drop down macro - changing colors Office 2010 64bit
Novice
VBA combination drop down macro - changing colors
 
Join Date: Apr 2017
Posts: 2
runke1tj is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 04-27-2017, 07:38 AM
gmaxey gmaxey is offline VBA combination drop down macro - changing colors Windows 7 32bit VBA combination drop down macro - changing colors Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,428
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 04-27-2017, 07:55 AM
runke1tj runke1tj is offline VBA combination drop down macro - changing colors Windows 7 64bit VBA combination drop down macro - changing colors Office 2010 64bit
Novice
VBA combination drop down macro - changing colors
 
Join Date: Apr 2017
Posts: 2
runke1tj is on a distinguished road
Default

Thank you so much gmaxey! It worked!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA combination drop down macro - changing colors changing drop down menus in a mail-merged document Taras49 Word 4 02-27-2017 11:30 AM
VBA combination drop down macro - changing colors 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
VBA combination drop down macro - changing colors Help with macro to set font colors Jennifer Murphy Word VBA 1 09-29-2013 09:57 PM
VBA combination drop down macro - changing colors Changing the placeholder text for drop down boxes DeadBatteries Word 1 08-24-2012 09:09 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:12 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft