?
Solved

Excel VBA Format Color

Posted on 2014-04-06
4
Medium Priority
?
460 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
MacroShadow earned 2000 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 27

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

719 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