Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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" wrote in message ... 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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" wrote in message ... 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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Setting Wall Color in 3-D charts | Charts and Charting in Excel | |||
Reading a color, and setting a value | Excel Programming | |||
Automatic color setting in Excel | Excel Discussion (Misc queries) | |||
Setting Color of PIE sections | Charts and Charting in Excel | |||
setting cell color | Excel Worksheet Functions |