Solved

Excel VBA Format Color

Posted on 2014-04-06
4
449 Views
Last Modified: 2014-04-06
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
Comment
Question by:shieldsco
  • 2
  • 2
4 Comments
 
LVL 26

Accepted Solution

by:
MacroShadow earned 500 total points
ID: 39981649
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
 

Author Comment

by:shieldsco
ID: 39981679
The code formats the Invoice Sheet only
0
 
LVL 26

Expert Comment

by:MacroShadow
ID: 39981684
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
 

Author Closing Comment

by:shieldsco
ID: 39981699
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now