How would I loop through open excel workbooks and if the cell A1 contains the word 'August, color A1 cell red. if A1 contains the word 'September' color it in blue.
Must loop though workbooks.
How would I loop through open excel workbooks and if the cell A1 contains the word 'August, color A1 cell red. if A1 contains the word 'September' color it in blue.
Must loop though workbooks.
Hi pablowilks, the following should do the trick![]()
Sub LoopThroughOpenWorkbooks() Dim wb As Workbook Dim ws As Worksheet Application.ScreenUpdating = False For Each wb In Workbooks For Each ws In wb.Sheets If ws.Range("A1").Value = "August" Then ws.Range("A1").Interior.Color = 255 ElseIf ws.Range("A1").Value = "September" Then ws.Range("A1").Interior.Color = 15773696 End If Next ws Next wb Application.ScreenUpdating = True End Sub
If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.
---Keep on Coding in the Free World---
thanks mordred
btw what does the Application.ScreenUpdating = False do?
thanks
Setting the Applicatioin.ScreenUpdating to False at the beginning prevents the screen from "flickering" while changes are being made to the worksheet.
Hi pablowilks,
If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks