Question : How would you automate the deletion of sheets with red highlighted cells in an xls file and saving these same sheets as csv files?

I have attached an xlsx file that contains ~ 20 sheets. Some of these sheets contain cells that are highlighted in red.  I would like help writing code that would automate the deleting of only the sheets that contain red highlighted cells. I would then like to convert each of these deleted sheets into csv files with name = sheet name. Thanks

Answer : How would you automate the deletion of sheets with red highlighted cells in an xls file and saving these same sheets as csv files?

I can't send you back your file because i'm using Excel 2003 and everything over column IV have been stripped off.  

Try this macro...
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
Sub ExportAndDelete()
    Dim s As Worksheet
    
    For Each s In Application.ActiveWorkbook.Sheets
        For Each c In s.UsedRange.Cells
            If c.Interior.ColorIndex = 3 Then
                s.SaveAs Application.ActiveWorkbook.Path & "\" & s.Name & ".CSV", xlCSV
                Application.DisplayAlerts = False
                s.Delete
                Application.DisplayAlerts = True
                Exit For
            End If
            DoEvents
        Next
    Next
End Sub
Open in New Window Select All
Random Solutions  
 
programming4us programming4us