Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
This is probably easier than I think...? Maybe this shouldn't even have been posted under Programming. I have a label - created from the toolbox - that shows a value (taken from a specific cell). If this value is 50% of another cell-value, I'd like it to change the background color to yellow. And if 100%, I'd like it to change to red. Like a dashboard. Same principle as Conditional Formatting for cells, but for labels instead. Any help is highly appreciated, Jan |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Jan,
Try: '============= Private Sub Worksheet_Change(ByVal Target As Range) Dim Rng1 As Range Dim Rng2 As Range Set Rng1 = Me.Range("A1") '<<==== CHANGE Set Rng2 = Me.Range("E2") '<<==== CHANGE If Not Intersect(Target, Union(Rng1, Rng2)) Is Nothing Then Select Case Rng1.Value / Rng2.Value Case 1: Me.Label1.BackColor = &H80FFFF Case 2: Me.Label1.BackColor = &HFF& Case Else: Me.Label1.BackColor = &H8000000F End Select End If End Sub '<<============= This is worksheet event code and should be pasted into the worksheets's code module (not a standard module and not the workbook's ThisWorkbook module): Right-click the worksheet's tab Select 'View Code' from the menu and paste the code. Alt-F11 to return to Excel. --- Regards, Norman "Jan" wrote in message ... Hi, This is probably easier than I think...? Maybe this shouldn't even have been posted under Programming. I have a label - created from the toolbox - that shows a value (taken from a specific cell). If this value is 50% of another cell-value, I'd like it to change the background color to yellow. And if 100%, I'd like it to change to red. Like a dashboard. Same principle as Conditional Formatting for cells, but for labels instead. Any help is highly appreciated, Jan |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, Norman. Great, fast reponse. The code even seems to make sense to an
amateur like me ! ;-) I still seem to be missing out on a detail somewhere, though, as I get the following message: 'Compile Error: Method or datamember not found' and then a highlighting of '.Label1' in the line Case 1: Me.Label1.BackColor = &H80FFFF ? I thought this was regards the naming of my label, but it is called Label1 - or how can I be sure. I'm just looking in the upper-left corner when highlighting the label and it says 'Label1'? Regards, Jan "Norman Jones" wrote: Hi Jan, Try: '============= Private Sub Worksheet_Change(ByVal Target As Range) Dim Rng1 As Range Dim Rng2 As Range Set Rng1 = Me.Range("A1") '<<==== CHANGE Set Rng2 = Me.Range("E2") '<<==== CHANGE If Not Intersect(Target, Union(Rng1, Rng2)) Is Nothing Then Select Case Rng1.Value / Rng2.Value Case 1: Me.Label1.BackColor = &H80FFFF Case 2: Me.Label1.BackColor = &HFF& Case Else: Me.Label1.BackColor = &H8000000F End Select End If End Sub '<<============= This is worksheet event code and should be pasted into the worksheets's code module (not a standard module and not the workbook's ThisWorkbook module): Right-click the worksheet's tab Select 'View Code' from the menu and paste the code. Alt-F11 to return to Excel. --- Regards, Norman "Jan" wrote in message ... Hi, This is probably easier than I think...? Maybe this shouldn't even have been posted under Programming. I have a label - created from the toolbox - that shows a value (taken from a specific cell). If this value is 50% of another cell-value, I'd like it to change the background color to yellow. And if 100%, I'd like it to change to red. Like a dashboard. Same principle as Conditional Formatting for cells, but for labels instead. Any help is highly appreciated, Jan |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Jan,
If you wish, you may send me your workbook: norman_jones@NOSPAMbtconnectDOTcom (Delete "NOSPAM" and replace"DOT" with a period (full stop)) By all means, delete other sheets and any sensitive data. --- Regards, Norman "Jan" wrote in message ... Thanks, Norman. Great, fast reponse. The code even seems to make sense to an amateur like me ! ;-) I still seem to be missing out on a detail somewhere, though, as I get the following message: 'Compile Error: Method or datamember not found' and then a highlighting of '.Label1' in the line Case 1: Me.Label1.BackColor = &H80FFFF ? I thought this was regards the naming of my label, but it is called Label1 - or how can I be sure. I'm just looking in the upper-left corner when highlighting the label and it says 'Label1'? Regards, Jan |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Format Data Labels | Excel Worksheet Functions | |||
Conditional Series Labels in Charts | Charts and Charting in Excel | |||
Chart Labels - Conditional Formating | Charts and Charting in Excel | |||
New Conditional Format Overriding Previous Conditional Format | Excel Discussion (Misc queries) | |||
Conditional Formatting - Data Labels | Charts and Charting in Excel |