karmanax.blogg.se

Macro conditional formatting excel 2016
Macro conditional formatting excel 2016





macro conditional formatting excel 2016

'Define a Range - For Example: you would need to enter this in the worksheet area 'as a legend and define a name for it as RngColor also in the Cells R7 to R1000 as a Dropdown - You can do this via conditional 'formating - listĪ(cl.Value _ 'For example if the Worksheet is Attendance ' - color if the cell's value is not found in the range ' - The line above won't change the cell's background Set rng = Intersect(Target, Range("R7:R1000")) ' Conditional Formatting for more than 3 conditions Private Sub Worksheet_SelectionChange(ByVal Target As Range) This can be modified quite easily by adjusting the ranges and so fourth.

macro conditional formatting excel 2016

This will change the cells in the range A to C on the checked row to Red if the value of the column C equals x, Green if it equals v and no color if it's anything else. Range("A" + CStr(Cell.Row) + ":C" + CStr(Cell.Row)).Interior.ColorIndex = xlNone Range("A" + CStr(Cell.Row) + ":C" + CStr(Cell.Row)).Interior.ColorIndex = 4 Range("A" + CStr(Cell.Row) + ":C" + CStr(Cell.Row)).Interior.ColorIndex = 3ĮlseIf Cell.Value = "v" Then ' Color it green

macro conditional formatting excel 2016

' Start checking each cell in the target range named ColorMagic for v's, x'es and nothings ' Define the range we wish to check against for x'es and v's. Private Sub Worksheet_Change(ByVal Target As Range) ' Run macro automaticly every time the Worksheet is changed After hacking a bit this is what I ended up with. I encountered a similar "problem" if you will today. MyRange.Rows(cell.row).Interior.ColorIndex = iColor 'checking the data in the first column only Private Sub Workbook_SheetChange(ByVal Sh as Object, ByVal Target as Range) The code is on my other computer and I want to do this quickly. I'm typing this in manually, so please excuse any typos. Hopefully, this suits your needs as well. I don't know if you've found the answer to this or not, but I ended up needing to figure this out for myself.







Macro conditional formatting excel 2016