Need help with Macro data color

sksanjeev786

Well-known Member
Joined
Aug 5, 2020
Messages
883
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi Team,

I have data in A to C column and I have pulled a few statements in columns E to G so now I need the same color that we have in Column B to C.


Book1
ABCDEFGHI
1Acknowledges Employees’ Cultural Traditions60%71%23
2Allows Relationships with Other Employees65%72%
3Can Be My Authentic Self61%82%
4Can Express My Passion & Creativity57%75%Can Express My Passion & Creativity57%75%
5Communicates Effectively63%82%Communicates Effectively63%82%
6Empowers Employees to Drive Change56%70%Encourages Collaboration/Teamwork63%72%
7Encourages Work/Life Balance57%83%Encourages Employees To Ask Questions64%75%
8Encourages Collaboration/Teamwork63%72%Encourages Employees To Try New Things57%78%
9Encourages Employees To Ask Questions64%75%Clear Growth & Development Plans59%23%
10Encourages Employees To Try New Things57%78%Fair & Equitable Compensation Policies61%83%
11Encourages Friendships with Coworkers62%63%Strict Policies Against Discrimination61%79%
12Feels Like a Connected Community61%71%Fun Place To Work61%74%
13Feels Like a Family55%61%
14Can Work My Way if I Meet Goals/Expectations65%78%
15Diverse & Inclusive Workplace61%74%
16Flexible Work Environment/Can Work Remotely59%33%
17Clear Growth & Development Plans59%23%
18Fair & Equitable Compensation Policies61%83%
19Strict Policies Against Discrimination61%79%
20Fun Place To Work61%74%
21Strong Fit With My Values58%72%
22Environmentally Responsible55%70%
23Highly Recommended by Current Employees58%76%
Sheet1
Cell Formulas
RangeFormula
F4:G12F4=INDEX($A:$C,MATCH($E4,$A:$A,0),F$1)
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
VBA Code:
Option Explicit
Sub color()
Dim lr&, i&, cell As Range, f
lr = Cells(Rows.Count, "A").End(xlUp).Row
For Each cell In Range("E4:E" & Cells(Rows.Count, "E").End(xlUp).Row)
    Set f = Range("A1:A" & lr).Find(cell.Value)
        For i = 1 To 2
            With cell.Offset(0, i).Font
                .color = f.Offset(0, i).Font.color
                .Bold = f.Offset(0, i).Font.Bold
            End With
        Next
Next
End Sub
 
Upvote 0
VBA Code:
Option Explicit
Sub color()
Dim lr&, i&, cell As Range, f
lr = Cells(Rows.Count, "A").End(xlUp).Row
For Each cell In Range("E4:E" & Cells(Rows.Count, "E").End(xlUp).Row)
    Set f = Range("A1:A" & lr).Find(cell.Value)
        For i = 1 To 2
            With cell.Offset(0, i).Font
                .color = f.Offset(0, i).Font.color
                .Bold = f.Offset(0, i).Font.Bold
            End With
        Next
Next
End Sub

Awesome!!!

Works very well.

Just wanted to check can we have the same thing as I have data in Sheet1 and Formula in Sheet 2. ( pulled data by using indirect function)

Thanks in Advance:)

Regards,
Sanjeev
 
Upvote 0
try again:
VBA Code:
Option Explicit
Sub color()
Dim lr&, i&, cell As Range, f
Worksheets("Sheet2").Activate
lr = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
For Each cell In Range("E4:E" & Cells(Rows.Count, "E").End(xlUp).Row)
    Set f = Worksheets("Sheet1").Range("A1:A" & lr).Find(cell.Value)
        For i = 1 To 2
            With cell.Offset(0, i).Font
                .color = f.Offset(0, i).Font.color
                .Bold = f.Offset(0, i).Font.Bold
            End With
        Next
Next
End Sub
 
Upvote 0
Solution
try again:
VBA Code:
Option Explicit
Sub color()
Dim lr&, i&, cell As Range, f
Worksheets("Sheet2").Activate
lr = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
For Each cell In Range("E4:E" & Cells(Rows.Count, "E").End(xlUp).Row)
    Set f = Worksheets("Sheet1").Range("A1:A" & lr).Find(cell.Value)
        For i = 1 To 2
            With cell.Offset(0, i).Font
                .color = f.Offset(0, i).Font.color
                .Bold = f.Offset(0, i).Font.Bold
            End With
        Next
Next
End Sub

Fantabulous!!!

Thank you so much Sir your help on this....!!!

Regards,
Sanjeev
 
Upvote 0

Forum statistics

Threads
1,215,089
Messages
6,123,058
Members
449,091
Latest member
ikke

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