Colour Entire Table Row Based on Values in Two Cells

daithiboy

Board Regular
Joined
Jul 1, 2016
Messages
50
Hi Folks,

I haven't had a chance to use VBA in quite awhile and so I've fallen out of practice.

I have a worksheet with 17,000 rows (growing by approx 1000 a month) and conditional formatting set to change the fill colour of some rows (entire table row) based on the values in column 12 and 13. This is proving very slow and every time I add more data it recalculates.

Seeing as my data won't be changed, I would like to get VBA to run through each row and permanently colour each table row based on what's in columns 12 and 13 i.e. if row x column 12 ="True" AND row x column 13 = "False" THEN colour entire row yellow (entire row = row x column 1 to row x column 13).

I hope that makes sense and if you have any suggestions they would be very much appreciated.

Many thanks,
Dave
 

Some videos you may like

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

daithiboy

Board Regular
Joined
Jul 1, 2016
Messages
50
If got this far,

Code:
Sub colour_rows()


Dim wsAtt As Worksheet
Dim lrow As Long
Dim i As Long


Set wsAtt = ThisWorkbook.Worksheets("All Attendances")
lrow = wsAtt.Cells(Rows.Count, 1).End(xlUp).Row






    With wsAtt
            
            For i = 2 To lrow
                
                If Cells(i, 12) = True And Cells(i, 13) = False Then
                
                    MsgBox "Urgent"
                    
                    ElseIf Cells(i, 12) = True And Cells(i, 13) = True Then
                    
                    MsgBox "Urgent DNA"
                                                        
                End If
                
                
            Next i
                      
    End With




End Sub


I just need to replace the message boxes with instructions to change the row colour.

Thanks a mil,
Dave
 

Watch MrExcel Video

Forum statistics

Threads
1,102,576
Messages
5,487,661
Members
407,608
Latest member
kjw

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top