AlwaysLearning2018
Board Regular
- Joined
- Nov 23, 2018
- Messages
- 51
Hi All,
I am struggling with writing vba code to highlight rows in certain colors based on the values in a cell, sometimes values based on multiple cells. I have the below spreadsheet, in which I am attempting to highlight rows green where column J (PostSt) has a value of "Deleted" in it. I am trying to highlight rows orange where column J has a value of "Not Posted" in it. Last, I am trying to highlight rows Blue in which column N (ReviewSt) has a value of "Not Reviewed", but also where column J (BC) does not equal "SA" in any value. I have the below code to highlight rows for the criteria I noted above in green and orange, but can't seem to figure out how to now highlight the rows Blue where column N is "Not Reviewed" but also where column J does NOT equal "SA". I was wondering if anyone would be able to help me out and maybe get me pointed in the correct direction? My task is that I must create VBA code to accomplish what I am trying to do, even though I know I can achieve this without. Any help would be so greatly appreciated. Thank you!!
Dim LastRow As Long, c As Range
Dim MyRange As Range
LastRow = Cells(Cells.Rows.Count, "M").End(xlUp).Row
Set MyRange = Range("M1:M" & LastRow)
For Each c In MyRange
If (c.Value) = "Deleted" Then
c.EntireRow.Interior.Color = 5287936
ElseIf (c.Value) = "Not Posted" Then
c.EntireRow.Interior.Color = 49407
Else
c.EntireRow.Interior.Color = xlNone
End If
Next
<TBODY>
</TBODY><COLGROUP><COL span=2><COL><COL><COL><COL><COL span=2><COL><COL><COL><COL><COL><COL></COLGROUP>
I am struggling with writing vba code to highlight rows in certain colors based on the values in a cell, sometimes values based on multiple cells. I have the below spreadsheet, in which I am attempting to highlight rows green where column J (PostSt) has a value of "Deleted" in it. I am trying to highlight rows orange where column J has a value of "Not Posted" in it. Last, I am trying to highlight rows Blue in which column N (ReviewSt) has a value of "Not Reviewed", but also where column J (BC) does not equal "SA" in any value. I have the below code to highlight rows for the criteria I noted above in green and orange, but can't seem to figure out how to now highlight the rows Blue where column N is "Not Reviewed" but also where column J does NOT equal "SA". I was wondering if anyone would be able to help me out and maybe get me pointed in the correct direction? My task is that I must create VBA code to accomplish what I am trying to do, even though I know I can achieve this without. Any help would be so greatly appreciated. Thank you!!
Dim LastRow As Long, c As Range
Dim MyRange As Range
LastRow = Cells(Cells.Rows.Count, "M").End(xlUp).Row
Set MyRange = Range("M1:M" & LastRow)
For Each c In MyRange
If (c.Value) = "Deleted" Then
c.EntireRow.Interior.Color = 5287936
ElseIf (c.Value) = "Not Posted" Then
c.EntireRow.Interior.Color = 49407
Else
c.EntireRow.Interior.Color = xlNone
End If
Next
TD</SPAN> | VD</SPAN> | Port</SPAN> | TN</SPAN> | SecID</SPAN> | Tdesc</SPAN> | Units </SPAN> | Price</SPAN> | OFV</SPAN> | BC</SPAN> | MGC</SPAN> | ApproveSt </SPAN> | PostSt</SPAN> | ReviewSt</SPAN> |
20190301</SPAN> | 20190409</SPAN> | 123</SPAN> | 22222</SPAN> | 123456789 </SPAN> | Matured</SPAN> | 1000</SPAN> | 100</SPAN> | 0</SPAN> | Waiting </SPAN> | Not Posted</SPAN> | Not Reviewed</SPAN> | ||
20190301</SPAN> | 20190409</SPAN> | 456</SPAN> | 555</SPAN> | 987654321 </SPAN> | Matured</SPAN> | 3000</SPAN> | 100</SPAN> | 0</SPAN> | Waiting</SPAN> | Deleted</SPAN> | Not Reviewed</SPAN> | ||
20190409</SPAN> | 20190409</SPAN> | 1</SPAN> | 888</SPAN> | 194563278 </SPAN> | Buy</SPAN> | 1</SPAN> | 0.01</SPAN> | 0</SPAN> | SA </SPAN> | INV</SPAN> | Pending</SPAN> | Posted</SPAN> | Not Reviewed</SPAN> |
20190409</SPAN> | 20190409</SPAN> | 2</SPAN> | 999</SPAN> | 986547230 </SPAN> | Buy</SPAN> | 1</SPAN> | 0.01</SPAN> | 0</SPAN> | SA </SPAN> | INV</SPAN> | Pending</SPAN> | Posted</SPAN> | Not Reviewed</SPAN> |
<TBODY>
</TBODY><COLGROUP><COL span=2><COL><COL><COL><COL><COL span=2><COL><COL><COL><COL><COL><COL></COLGROUP>