need same color as per row 1

sksanjeev786

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

Can i get the color based on the row 1 font color in Row 4

everytime row 4 order will change


book3
ABCDEFGHIJKLMNOPQRSTU
1Used the brandStore shelfFriends or familySaw AOTC using itStore ads / signsOnline tobacco retailer websiteSocial media post by AOTCStore clerkBrand's websiteWeb adWeb searchBrand’s social mediaBrand rewards programSaw at an eventTextEmailCouponPiece of mailCustomer serviceSaw a TV ad at a gas station
2
3
4Color based on Row 1Used the brandStore shelfStore ads / signsSaw AOTC using itFriends or familySocial media post by AOTCStore clerkBrand's websiteOnline tobacco retailer websiteBrand’s social mediaWeb searchSaw a TV ad at a gas stationBrand rewards programCouponWeb adSaw at an eventEmailPiece of mailTextCustomer service
Sheet1
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
I don't think it is possible with formulas only. You can use simple macro to do it.

Like:

VBA Code:
Sub copy_color()
  Dim i As Long, lc As Long
  lc = WorksheetFunction.Max(Cells(1, Columns.Count).End(xlToLeft).Column, Cells(4, Columns.Count).End(xlToLeft).Column)
  For i = 2 To lc
    Cells(4, i).Font.Color = Cells(1, i).Font.Color
  Next i
End Sub
 
Upvote 0
I don't think it is possible with formulas only. You can use simple macro to do it.

Like:

VBA Code:
Sub copy_color()
  Dim i As Long, lc As Long
  lc = WorksheetFunction.Max(Cells(1, Columns.Count).End(xlToLeft).Column, Cells(4, Columns.Count).End(xlToLeft).Column)
  For i = 2 To lc
    Cells(4, i).Font.Color = Cells(1, i).Font.Color
  Next i
End Sub
Hi Sir,

thanks for checking but look like color are not matching for few stubs
I have bordered them Cell D1 and F4 and I1 and H4 for example

book2
ABCDEFGHIJKLMNOPQRSTU
1Used the brandStore shelfFriends or familySaw AOTC using itStore ads / signsOnline tobacco retailer websiteSocial media post by AOTCStore clerkBrand's websiteWeb adWeb searchBrand’s social mediaBrand rewards programSaw at an eventTextEmailCouponPiece of mailCustomer serviceSaw a TV ad at a gas station
2
3
4Color based on Row 1Used the brandStore shelfStore ads / signsSaw AOTC using itFriends or familySocial media post by AOTCStore clerkBrand's websiteOnline tobacco retailer websiteBrand’s social mediaWeb searchSaw a TV ad at a gas stationBrand rewards programCouponWeb adSaw at an eventEmailPiece of mailTextCustomer service
Sheet2
 
Upvote 0
Looks like you need the Fonts Bolded as well

Rich (BB code):
  For i = 2 To lc
    Cells(4, i).Font.Color = Cells(1, i).Font.Color
    Cells(4, i).Font.Bold = True
  Next i
 
Upvote 0
Looks like you need the Fonts Bolded as well

Rich (BB code):
  For i = 2 To lc
    Cells(4, i).Font.Color = Cells(1, i).Font.Color
    Cells(4, i).Font.Bold = True
  Next i
yes! but color are not matching as per row 1 attribute...

for example "Friends or family" row1 and row 4 "Friends or family" is differ so I need as per row 1
 
Upvote 0
They match for me if they are bolded (actually the colour matched anyway, they just needed bolding to appear the same)
 
Upvote 0
Or are you saying you need to search for the text and then change the colour to match?
 
Upvote 0
Or are you saying you need to search for the text and then change the colour to match?
If the above try...

VBA Code:
Sub copy_color2()
    Dim i As Long, lc As Long, myRng As Range, fndCell As Range
    Application.ScreenUpdating = False
 
    lc = WorksheetFunction.Max(Cells(1, Columns.Count).End(xlToLeft).Column, Cells(4, Columns.Count).End(xlToLeft).Column)
    Set myRng = Range(Cells(1, 1), Cells(1, lc))
 
    For i = 2 To lc
        Set fndCell = myRng.Find(Cells(4, i), Cells(1, 1), xlValues, xlWhole, xlByColumns, xlNext)
   
        Cells(4, i).Font.Color = fndCell.Font.Color
        Cells(4, i).Font.Bold = True
    Next i

End Sub
 
Upvote 0
Solution
If the above try...

VBA Code:
Sub copy_color2()
    Dim i As Long, lc As Long, myRng As Range, fndCell As Range
    Application.ScreenUpdating = False
 
    lc = WorksheetFunction.Max(Cells(1, Columns.Count).End(xlToLeft).Column, Cells(4, Columns.Count).End(xlToLeft).Column)
    Set myRng = Range(Cells(1, 1), Cells(1, lc))
 
    For i = 2 To lc
        Set fndCell = myRng.Find(Cells(4, i), Cells(1, 1), xlValues, xlWhole, xlByColumns, xlNext)
  
        Cells(4, i).Font.Color = fndCell.Font.Color
        Cells(4, i).Font.Bold = True
    Next i

End Sub

Wow!! thank you so much for your support and help :)
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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