Link to home
Start Free TrialLog in
Avatar of x5225642
x5225642

asked on

Extract all cells with red font colour

I've already got a macro that returns the names of folders and the documents within them into Excel in a hierarchical type structure. The document names are returned in red text and I now need a script that copies the red text only and paste them into column A of sheet 2. Has anyone got any suggestions? I just can't get my head round how to do this.
Avatar of Mohammed Rahman
Mohammed Rahman
Flag of India image

Start recording macro..apply filter to the first row..filter data by color (red text).. Select first red text cell..hold ctrl+shift and press down arrow to select data in entire column, ctrl+c to copy..go to sheer 2..select the cell and press ctrl+v to paste entite ref text data. Stop recording macro..press alt+f11 to open developer view and there you will have the script (macro). If the red text spans multiple columns, while holding shift+ctrl, press down arrow once and then right arrow once. This will always select the entire red text, itrespective of number of rows and columns (which can vary time to time)
ASKER CERTIFIED SOLUTION
Avatar of Mlanda T
Mlanda T
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you are using one of the newer versions of Excel the best way is to Filter by Color

Option Explicit

Sub FilterRed()

    If Not ActiveSheet.AutoFilterMode Then ActiveSheet.Range("A1").AutoFilter
    
    ActiveSheet.Range("$A1").CurrentRegion.AutoFilter Field:=1, Criteria1:=RGB(255, 0 _
        , 0), Operator:=xlFilterCellColor
End Sub

Open in new window

It might even be a good idea to modify the original routine to place the document names in Sheet2 while they are being retrieved. If you could post that routine we can show you how to modify it.
I've requested that this question be closed as follows:

Accepted answer: 250 points for mody2579's comment #a41009306
Assisted answer: 250 points for MlandaT's comment #a41009307

for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.