+ Reply to Thread
Results 1 to 2 of 2

Want add color to the cell depending on the value selected from th

  1. #1
    viksha
    Guest

    Want add color to the cell depending on the value selected from th

    Hi,

    I have defined a dropdown, by using a Data>Validation>List..

    Now it has got 5 values say 1 ,2 ,3, 4 and 5

    Now my requirement is , I wnat to change the color of the cell depending on
    the value I select from the text.say if 1 is selected then it should be red
    and 2 is selected it should be greeen and so on..

    I tried using FORMAT>CONTIONAL..but this is restricted to only 4 , I have
    condtion to check for more than 4 say 5 or 6..

    Looking forward for reply.
    --
    Programmin

  2. #2
    Tom Ogilvy
    Guest

    Re: Want add color to the cell depending on the value selected from th

    Use the change event:

    Chip Pearson's page on Events
    http://www.cpearson.com/excel/events.htm


    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim v as Variant
    v = Array(3, 4,5,8,6)
    if not Intersect(target,Range("B9:B20")) is nothing then
    if Target.Value > 0 and Target.Value < 6
    Target.Interior.ColorIndex = v(Target.Value-1)
    end if
    end if
    End Sub

    --
    Regards,
    Tom Ogilvy


    Right click on the sheet tab and select view code. Put in code like the
    above.
    "viksha" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > I have defined a dropdown, by using a Data>Validation>List..
    >
    > Now it has got 5 values say 1 ,2 ,3, 4 and 5
    >
    > Now my requirement is , I wnat to change the color of the cell depending

    on
    > the value I select from the text.say if 1 is selected then it should be

    red
    > and 2 is selected it should be greeen and so on..
    >
    > I tried using FORMAT>CONTIONAL..but this is restricted to only 4 , I have
    > condtion to check for more than 4 say 5 or 6..
    >
    > Looking forward for reply.
    > --
    > Programmin




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1