Excel 2019
Windows 10
I wish to colour all rows, from Column A - Column G that contains data
using 2 alternaing RGB colours on a specific called Results.
I want to do this using VBA as I am using VBA to pull data from various other
worksheets into the Results sheet.
so...
Row 1 = RGB(179, 230, 255)
Row 2 = RGB(255, 255, 197)
Row 3 =RGB(179, 230, 255)
Row 4 = RGB(255, 255, 197)
and so on down the columns.
I have a existing VBA code (macro) that colours a different sheet based on matching rows but I am struggling
to adapt it to the criteria above.
While searching this forum (and google) before posting I found this thread HERE
The user was asking how to colour every other row only and again I have struggled to adapt it to my needs.
Could someone kindly help me out?
Windows 10
I wish to colour all rows, from Column A - Column G that contains data
using 2 alternaing RGB colours on a specific called Results.
I want to do this using VBA as I am using VBA to pull data from various other
worksheets into the Results sheet.
so...
Row 1 = RGB(179, 230, 255)
Row 2 = RGB(255, 255, 197)
Row 3 =RGB(179, 230, 255)
Row 4 = RGB(255, 255, 197)
and so on down the columns.
I have a existing VBA code (macro) that colours a different sheet based on matching rows but I am struggling
to adapt it to the criteria above.
VBA Code:
Sub ColourAlternateRows()
With Application
.ScreenUpdating = False
End With
Dim Cl As Range
Dim lngRow As Long
With CreateObject("scripting.dictionary")
For Each Cl In Range("E2", Range("E" & Rows.Count).End(xlUp))
If Not .Exists(Cl.Value) Then .Add Cl.Value, (.Count Mod 2)
lngRow = Cl.Row
If .Count Mod 2 = 0 Then
Range(Cells(lngRow, "A"), Cells(lngRow, "G")).Interior.Color = RGB(179, 230, 255)
Else
Range(Cells(lngRow, "A"), Cells(lngRow, "G")).Interior.Color = RGB(255, 255, 197)
End If
Next Cl
End With
With Application
.ScreenUpdating = True
End With
End Sub
While searching this forum (and google) before posting I found this thread HERE
The user was asking how to colour every other row only and again I have struggled to adapt it to my needs.
VBA Code:
Sub ColorAlternate()
Dim LR As Long, i As Long
'Stop the screen from flickering
Application.ScreenUpdating = False
'Find the last filled row in column A
LR = Range("A" & Rows.Count).End(xlUp).Row
'Loop through the filled rows in steps of 2
For i = 2 To LR Step 2
'Colour alternate rows
Rows(i).EntireRow.Interior.ColorIndex = 6
Next i
'Turn screen updating on again
Application.ScreenUpdating = True
End Sub
Could someone kindly help me out?