Results 1 to 2 of 2

Thread: change color of a cell based on drop down selection

  1. #1

    change color of a cell based on drop down selection



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi

    In cell a1 we have drop down selection(black, white, red and blue). If i select black then color of cell b1 should be black and if selection is red then cell color of b1 should be red and so on.
    Please assist on above query.

  2. #2
    Conjurer WizzardOfOz's Avatar
    Join Date
    Sep 2013
    Location
    Australia
    Posts
    184
    Articles
    0
    The easiest is to
    1: Set a named range to a list of colours
    2: Set the OnChange event for that column (or range)

    Have a look at http://www.cpearson.com/excel/colors.aspx

    Assuming you have not set your default colour pallet then this should work
    Pallet is: Black, White, Red, Green, Blue, Yellow, Magenta, Cyan

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 1 Then Target.Interior.ColorIndex = Application.Match(Target.Value2, Range("colours"), 0)
    End Sub

    Otherwise have an array of RGB and lookup the colour in the array.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •