Thread: [Solved] Macro Needed with RGB
View Single Post
 
Old 02-12-2019, 01:11 PM
NoSparks NoSparks is offline Windows 7 64bit Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

Perhaps you can glean something from this.
Needs to be in a .xlsm in the same folder as those listed files.
Needs list of files to work on starting in A1.
Code:
Sub ChangeRGB()
    
Dim wb As Workbook, ws As Worksheet
Dim i As Long, cel As Range
Dim fPath As String, arr As Variant

fPath = ThisWorkbook.Path

arr = Range("A1", Range("A" & Rows.Count).End(xlUp)).Value

Application.ScreenUpdating = False
For i = LBound(arr) To UBound(arr)
    On Error Resume Next    'incase file doesn't exist
    Set wb = Workbooks.Open(Filename:=fPath & "\" & arr(i, 1) & ".xlsx")
    On Error GoTo 0         'reinstate error notification
    If Not wb Is Nothing Then
        With wb
            For Each ws In wb.Sheets
                For Each cel In Intersect(ws.Range("A:A"), ws.UsedRange)
                    If cel.Interior.Color = RGB(0, 0, 0) Then
                        cel.Resize(, 14).Interior.Color = RGB(192, 192, 192)
                    End If
                Next cel
            Next ws
            wb.Close (True)
        End With
    Else
        MsgBox "Workbook not found:" & vbLf & vbLf & arr(i, 1) & ".xlsx"
    End If
    Set wb = Nothing
Next i
Application.ScreenUpdating = True
End Sub
Hope that helps.
Reply With Quote