VBA CODE COLOR

newbieDB

New Member
Joined
Feb 15, 2023
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hey I just wanted to know if its possible to copy ROW Colors from sheet 2 into sheet 1 by a condition. The condition Would be the value coloumn A on each row is the same on as on sheet 1.

For example

Sheet 2 Table
Johannes (This row has the color red)A
Peter
(This row has the color green)
B
kristine
(This row has the color blue)
DE
Ulrike
(This row has the color yellow)
ENG

Sheet 1 Table



Peter DE
Klein DipsyA
JohannesENG
John DoeFr
Max MusterhaseTr
UlrikeGr

Now the first row with Peter on A1 should get green for the whole row
Second row Shouldnt be touched
Third Row Red
And the last row yellow

As you can see, sheet 1 has more Rows than sheet 2.

The easiest way for me would smthg be like index match with coloumn A and just copy the color to whole row.

A way it could work in my opinion would be to make two arrays. Array 1 Has Sheet 2 and Array2 sheet 1. Now comparing both arrays. Side note Sheet 1 has all values that sheet 2 has.
traverse and compare coloumn A values on array1 index one with all array2 values .
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hi
What about
VBA Code:
Sub test()
Dim x
Dim i
With Sheets("sheet2")
For i = 1 To Sheets("sheet1").Cells(Rows.Count, 1).End(xlUp).Row
x = Application.Match(Cells(i, 1), .Cells(1, 1).Resize(.Cells(Rows.Count, 1).End(xlUp).Row), 0)
If IsNumeric(x) Then
Cells(i, 1).Interior.Color = .Cells(x, 1).Interior.Color
End If
Next
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,883
Messages
6,175,167
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top