Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
CF or VBA
In a sheet with (max)10000 rows, any of the rows could be shaded green(when
criteria 1 is met), orange (criteria 2), or red (3). The criteria will appear in column "AB" by formula e.g. =IF($S410,"W",""). This formula will change as I add bits to it but the premise is that the code needs to look at column AB and deal with whatever result is displayed by the formula (max of 3. If the criteria in any cell in "AB" alters or is removed entirely, the row will need to reflect this. How would I do this by code? -- Traa Dy Liooar Jock |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
CF or VBA
In this example the formulae in column AB will return "G" or "O" or "R" for
green or orange or red. It is event code to be inserted in the worksheet code area: Private Sub Worksheet_Calculate() Dim n As Long n = Cells(Rows.Count, "AB").End(xlUp).Row For i = 1 To n codee = Cells(i, "AB").Value Select Case codee Case "G" clr = 10 Case "O" clr = 46 Case "R" clr = 3 Case Else clr = xlNone End Select With Cells(i, "AB").EntireRow .Interior.ColorIndex = clr End With Next End Sub Because it is worksheet code, it is very easy to install and use: 1. right-click the tab name near the bottom of the window 2. select View Code - this brings up a VBE window 3. paste the stuff in and close the VBE window If you save the workbook, the macro will be saved with it. To remove the macro: 1. bring up the VBE windows as above 2. clear the code out 3. close the VBE window To learn more about macros in general, see: http://www.mvps.org/dmcritchie/excel/getstarted.htm To learn more about Event Macros (worksheet code), see: http://www.mvps.org/dmcritchie/excel/event.htm -- Gary''s Student - gsnu200852 "Jock" wrote: In a sheet with (max)10000 rows, any of the rows could be shaded green(when criteria 1 is met), orange (criteria 2), or red (3). The criteria will appear in column "AB" by formula e.g. =IF($S410,"W",""). This formula will change as I add bits to it but the premise is that the code needs to look at column AB and deal with whatever result is displayed by the formula (max of 3. If the criteria in any cell in "AB" alters or is removed entirely, the row will need to reflect this. How would I do this by code? -- Traa Dy Liooar Jock |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
CF or VBA
Thanks.
Can you make two changes? 1) Columns in the sheet are already formatted with colour to visually group certain ones together. Your code strips all colour from all rows from the active cell in AB up unless one of the options is selected in the active cell in which case the relevant colour is applied to the active row. 2) When the option is deleted from the active cell in AB, the vba applied colour remains on the active row. Can the code: 1) ignore all row formatting except for the active row, and 2) when an option is removed from AB, return the row to its original formatting (the same as row 3 for instance)? Thanks again -- Traa Dy Liooar Jock "Gary''s Student" wrote: In this example the formulae in column AB will return "G" or "O" or "R" for green or orange or red. It is event code to be inserted in the worksheet code area: Private Sub Worksheet_Calculate() Dim n As Long n = Cells(Rows.Count, "AB").End(xlUp).Row For i = 1 To n codee = Cells(i, "AB").Value Select Case codee Case "G" clr = 10 Case "O" clr = 46 Case "R" clr = 3 Case Else clr = xlNone End Select With Cells(i, "AB").EntireRow .Interior.ColorIndex = clr End With Next End Sub Because it is worksheet code, it is very easy to install and use: 1. right-click the tab name near the bottom of the window 2. select View Code - this brings up a VBE window 3. paste the stuff in and close the VBE window If you save the workbook, the macro will be saved with it. To remove the macro: 1. bring up the VBE windows as above 2. clear the code out 3. close the VBE window To learn more about macros in general, see: http://www.mvps.org/dmcritchie/excel/getstarted.htm To learn more about Event Macros (worksheet code), see: http://www.mvps.org/dmcritchie/excel/event.htm -- Gary''s Student - gsnu200852 "Jock" wrote: In a sheet with (max)10000 rows, any of the rows could be shaded green(when criteria 1 is met), orange (criteria 2), or red (3). The criteria will appear in column "AB" by formula e.g. =IF($S410,"W",""). This formula will change as I add bits to it but the premise is that the code needs to look at column AB and deal with whatever result is displayed by the formula (max of 3. If the criteria in any cell in "AB" alters or is removed entirely, the row will need to reflect this. How would I do this by code? -- Traa Dy Liooar Jock |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|