Forum Discussion

MARK JENKINS's avatar
MARK JENKINS
Copper Contributor
Apr 26, 2018

making a list from different tabs within an excel sheet based on the colour of the cell

I want to make a list based on the colour of the cell from different tabs within an excel sheet. How do I do this?

2 Replies

  • Matt Mickle's avatar
    Matt Mickle
    Bronze Contributor

    Just wanted to follow up and see if you had resolved your issue?

  • Matt Mickle's avatar
    Matt Mickle
    Bronze Contributor

    You can use a macro to get the result you would like, otherwise I don't think it's possible.  Please see attached example workbook.  Since, I cannot attach a macro enabled file you will need to paste this code into a new code module by doing the following:

     

    1. Use Alt + F11 to access the Visual Basic Editor

    2. Click Insert > Module

    3. Paste this code into the "blank" window

    4. Hit the "Play" button (Green Triangle on the task bar) to run the macro

     

    Sub GetColorsAndList()
    
        Dim sht As Worksheet
        Dim Counter As Integer
        'Cycle through worksheets
        For Each sht In ActiveWorkbook.Worksheets
            If sht.Name <> "Results" Then
                'Get the color of Cell A1 and Print to Results Worksheet
                'Using Copy and Paste ---> Change the cell reference as needed
                sht.Range("A1").Copy Sheets("Results").Range("A" & Counter + 1)
                'Put the parent sheet in the cell on Results tab
                Sheets("Results").Range("A" & Counter + 1) = sht.Name
                Counter = Counter + 1
            End If
        Next sht
    
    End Sub
    

    The results will look like this:

     

Resources