RobBan67
New Member
- Joined
- Jan 23, 2021
- Messages
- 6
- Office Version
- 365
- Platform
- Windows
Hello everyone.
First of all, I’m a VBA rookie, so please bare with me
This is what I’m trying to do.
I have one sheet (Project List) with a table (Table1) that looks like this.
What I’m trying to achieve is to set a specific background color to every third row
based on the color Index in another Sheet called (Data), that l looks like this.
So, I want the script to search for the “customer” name in the sheet Data and return the right color for each Customer to the Project List color the with the right color.
I found this code online that I tried to modify to fit my needs, but without succsess.
Right now the script only color the first two “Customers” but color the both of them with the color of the first customer (Walker & Son).
I hope I can get some help and guidance to make this work, because this is beyond my knowledge ?
Thanks!
First of all, I’m a VBA rookie, so please bare with me
This is what I’m trying to do.
I have one sheet (Project List) with a table (Table1) that looks like this.
What I’m trying to achieve is to set a specific background color to every third row
based on the color Index in another Sheet called (Data), that l looks like this.
So, I want the script to search for the “customer” name in the sheet Data and return the right color for each Customer to the Project List color the with the right color.
I found this code online that I tried to modify to fit my needs, but without succsess.
Right now the script only color the first two “Customers” but color the both of them with the color of the first customer (Walker & Son).
I hope I can get some help and guidance to make this work, because this is beyond my knowledge ?
Thanks!
VBA Code:
Sub Color_Project()
Dim MyRange As Range
Dim RowSelect As Range
Dim SeekValue As Range
Dim ReturnValue As Range
Dim i As Integer
Set SeekValue = Sheets("Project List").Range("Table1[Customer]")
Set ReturnValue = Sheets("Data").Range("Data[Customer]")
Set MyRange = Sheets("Project List").Range("Table1")
Set RowSelect = MyRange.Rows(5)
For i = 1 To RowSelect.Rows.Count Step 4
Set RowSelect = Union(RowSelect, MyRange.Rows(i))
For Each Datacell In SeekValue
For Each ColorValueCell In ReturnValue
If Datacell.Value = ColorValueCell.Value Then
Set ColorIndexCell = Sheets("Data").Range("C" & ColorValueCell.Row)
RowSelect.Interior.ColorIndex = ColorIndexCell.Value
End If
Next
Next
Next
End Sub