Summary sheet colour

mattless1

Board Regular
Joined
Apr 1, 2011
Messages
102
Hi All,

I have a summary sheet with all my suppliers on it.
is there a way I can colour the supplier names in the summary sheet with colour of their tabs.

thanks in advance.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
VBA below assumes
- supplier name is in column A of sheet named "Summary"
- supplier name on tab is the SAME as supplier name in sheet "Summary"
Code:
Sub ColorSupplier()
    Dim supplier As Range, ws As Worksheet
    For Each supplier In Sheets("Summary").Range("A2", Sheets("Summary").Range("A" & Rows.Count).End(xlUp))
        For Each ws In ThisWorkbook.Sheets
            If UCase(ws.Name) = UCase(supplier) Then
                supplier.Interior.Color = ws.Tab.Color
                Exit For
            End If
        Next ws
    Next supplier
End Sub
 
Upvote 0
Hi Yongle
thanks, but the code didn't work for me. A4 is the start location of the supplier names, I tried changing the cell ref in script to that cell, but nothing worked.

thanks,
Larry
 
Upvote 0
Are the supplier names in column A exactly the same as the sheet names?
 
Upvote 0
As a test what happens if you run this
Code:
Sub mattless1()
    With Sheets("summary").Range("A4")
        .Interior.Color = Sheets(.Value).Tab.Color
    End With
End Sub
 
Upvote 0
In that case if the code is in the same workbook as the summary sheet, Yongle's code should work.
If you have put the code in a different workbook, try
Code:
Sub ColorSupplier()
    Dim supplier As Range, ws As Worksheet
    For Each supplier In Sheets("Summary").Range("A4", Sheets("Summary").Range("A" & Rows.Count).End(xlUp))
        For Each ws In ActiveWorkbook.Sheets
            If UCase(ws.Name) = UCase(supplier) Then
                supplier.Interior.Color = ws.Tab.Color
                Exit For
            End If
        Next ws
    Next supplier
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,190
Members
452,616
Latest member
intern444

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