Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: James Rivera   on Dec 23 In MS Office Category.

  
Question Answered By: Adelgiese Fischer   on Dec 23

You put the number for each color  (eg 255 for red) you want in the cell to the
right of the validation  item in the validation source table.

Then you create a named range "colors" to include the validation items and the
color numbers to the right.

Then create a named range "datarange2" to include all the cells where the
validation method is used but not the validation table.

Then put this into the worksheet code  ( right click the worksheet tab and
click view code).

Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Range("datarange2"), Target) Is Nothing Then
Dim requiredcolor As String
requiredcolor = WorksheetFunction.VLookup(Target.Text, Range("colors"), 2,
False)
Target.Interior.Color = requiredcolor
End If
End Sub

The color numbers are the decimal equivalent of the hex value as follows

first 2 characters Blue
Middle two characters Green
Right two characters Red

So FF0000 is Blue and converted from Hex to decimal is 16711680

Use the calculator function to convert.

As regards part 2 you might need to give me a bit more info. It is certainly
feasible but I need to know where the cells, color numbers, totals etc are.
In essence you would probably need a function which looks at each cell,
evaluates its interior.color, and then counts it.

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Can you color code a Validation List Or get search suggestion and latest updates.


Tagged: