AnswerSeeker
03-14-2012, 11:03 PM
Hello,
I wrote a VBA code where cells are colored regarding some specific content. The code should be executed for all worksheets, but it is doing so only in the active worksheet.
Here the code:
Sub Color()
Dim wkSht As Worksheet
For Each wkSht In ActiveWorkbook.Worksheets
Dim paint As Range
For Each paint In Range("A1:BB500")
If paint.Value = "MO" Then
paint.Interior.Color = vbCyan
ElseIf paint.Value = "FO" Then
paint.Interior.Color = vbGreen
ElseIf paint.Value = "BO" Then
paint.Interior.Color = vbRed
ElseIf paint.Value = "VR" Then
paint.Interior.Color = vbYellow
End If
Next paint
Next wkSht
End Sub
Hope someone can help me?!
I wrote a VBA code where cells are colored regarding some specific content. The code should be executed for all worksheets, but it is doing so only in the active worksheet.
Here the code:
Sub Color()
Dim wkSht As Worksheet
For Each wkSht In ActiveWorkbook.Worksheets
Dim paint As Range
For Each paint In Range("A1:BB500")
If paint.Value = "MO" Then
paint.Interior.Color = vbCyan
ElseIf paint.Value = "FO" Then
paint.Interior.Color = vbGreen
ElseIf paint.Value = "BO" Then
paint.Interior.Color = vbRed
ElseIf paint.Value = "VR" Then
paint.Interior.Color = vbYellow
End If
Next paint
Next wkSht
End Sub
Hope someone can help me?!