Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 463
  • Last Modified:

Excel VBA Format Color

I need to format a row range: A1:T1, Color Green and Font Black on all worksheets except for 2 (Invoice Sheet and Summary Sheet).
0
shieldsco
Asked:
shieldsco
  • 2
  • 2
1 Solution
 
MacroShadowCommented:
Run this macro:
Sub Demo()

    Dim ws As Worksheet

    For Each ws In ActiveWorkbook.Worksheets
        If ws.Name <> "Invoice Sheet" And ws.Name <> "Summary Sheet" Then
            Range("A1:T1").Interior.Color = vbGreen
            Range("A1:T1").Font.Color = vbBlack
        End If
    Next
    
End Sub

Open in new window

0
 
shieldscoAuthor Commented:
The code formats the Invoice Sheet only
0
 
MacroShadowCommented:
Sorry missing one line:
Sub Demo()

    Dim ws As Worksheet

    For Each ws In ActiveWorkbook.Worksheets
        If ws.Name <> "Invoice Sheet" And ws.Name <> "Summary Sheet" Then
            ws.Activate
            Range("A1:T1").Interior.Color = vbGreen
            Range("A1:T1").Font.Color = vbBlack
        End If
    Next

End Sub

Open in new window

0
 
shieldscoAuthor Commented:
I figured it out. Code below:

For Each wsDst In ThisWorkbook.Sheets
        If wsDst.Name <> "Invoice" And wsDst.Name <> "Summary" Then
        With wsDst
            .Range("A1:T1").Interior.Color = vbGreen
            .Range("A1:T1").Font.Color = vbBlack
            End With
        End If
    Next
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now