+ Reply to Thread
Results 1 to 3 of 3

Setting values by row color

  1. #1
    Ron
    Guest

    Setting values by row color

    Hi,

    I need to set the values (Peoples names) of a column according to the fill
    color of each row.

    Can anyone please point me in the right direction with this problem.

    I'm a VBA newbie by the way!


    Regards,
    Ron.

  2. #2
    Bob Phillips
    Guest

    Re: Setting values by row color


    Private Sub Worksheet_Change(ByVal Target As Range)
    Const WS_RANGE As String = "H1:H10"

    On Error GoTo ws_exit:
    Application.EnableEvents = False
    If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
    With Target
    Select Case .Interior.ColorIndex
    Case 3: .Value = "Bill" 'red
    Case 6: .Value = "John" 'yellow
    Case 5: .Value = "Ron" 'blue
    Case 10: .Value = "Alan" 'green
    'etc.
    End Select
    End With
    End If

    ws_exit:
    Application.EnableEvents = True
    End Sub

    'This is worksheet event code, which means that it needs to be
    'placed in the appropriate worksheet code module, not a standard
    'code module. To do this, right-click on the sheet tab, select
    'the View Code option from the menu, and paste the code in.


    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Ron" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > I need to set the values (Peoples names) of a column according to the fill
    > color of each row.
    >
    > Can anyone please point me in the right direction with this problem.
    >
    > I'm a VBA newbie by the way!
    >
    >
    > Regards,
    > Ron.




  3. #3
    Ron
    Guest

    Re: Setting values by row color

    Thanks Bob,

    That works fine> I will have to iterate through the rows though because the
    event type doesn't quite suit the way the sheet will be used.


    Regards,
    Ron.

    "Bob Phillips" wrote:

    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    > Const WS_RANGE As String = "H1:H10"
    >
    > On Error GoTo ws_exit:
    > Application.EnableEvents = False
    > If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
    > With Target
    > Select Case .Interior.ColorIndex
    > Case 3: .Value = "Bill" 'red
    > Case 6: .Value = "John" 'yellow
    > Case 5: .Value = "Ron" 'blue
    > Case 10: .Value = "Alan" 'green
    > 'etc.
    > End Select
    > End With
    > End If
    >
    > ws_exit:
    > Application.EnableEvents = True
    > End Sub
    >
    > 'This is worksheet event code, which means that it needs to be
    > 'placed in the appropriate worksheet code module, not a standard
    > 'code module. To do this, right-click on the sheet tab, select
    > 'the View Code option from the menu, and paste the code in.
    >
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "Ron" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi,
    > >
    > > I need to set the values (Peoples names) of a column according to the fill
    > > color of each row.
    > >
    > > Can anyone please point me in the right direction with this problem.
    > >
    > > I'm a VBA newbie by the way!
    > >
    > >
    > > Regards,
    > > Ron.

    >
    >
    >


+ 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