Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Excel VBA Format Text

Posted on 2014-04-07
3
Medium Priority
?
380 Views
Last Modified: 2014-04-07
I need to format multiple Columns A,D,I,L Text on all worksheets except for 2 (Invoice and Summary).
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
3 Comments
 
LVL 27

Expert Comment

by:MacroShadow
ID: 39982937
Use this macro:
Sub Demo()

    Dim ws As Worksheet

    For Each ws In ActiveWorkbook.Worksheets
        With ws
            If .Name <> "Invoice Sheet" And .Name <> "Summary Sheet" Then
                .Range("A:A").Interior.Color = vbRed    ' or whatever formatting you want
                .Range("D:D").Interior.Color = vbGreen    ' or whatever formatting you want
                .Range("I:I").Interior.Color = vbCyan    ' or whatever formatting you want
                .Range("L:L").Interior.Color = vbBlue    ' or whatever formatting you want
            End If
        End With
    Next

End Sub

Open in new window

0
 

Author Comment

by:shieldsco
ID: 39982963
I get the following runtime error 1004 method range of object _worksheet failed on  .Range("A").NumberFormat = "@"

Code:
Sub Demo()

    Dim ws As Worksheet

    For Each ws In ActiveWorkbook.Worksheets
        With ws
            If .Name <> "Invoice Sheet" And .Name <> "Summary Sheet" Then
                .Range("A").NumberFormat = "@"
                .Range("D").NumberFormat = "@"
                .Range("L").NumberFormat = "@"
            End If
        End With
    Next

End Sub
0
 
LVL 27

Accepted Solution

by:
MacroShadow earned 2000 total points
ID: 39982974
Sub Demo()

    Dim ws As Worksheet

    For Each ws In ActiveWorkbook.Worksheets
        With ws
            If .Name <> "Invoice Sheet" And .Name <> "Summary Sheet" Then
                .Range("A:A").NumberFormat = "@"
                .Range("D:D").NumberFormat = "@"
                .Range("I:I").NumberFormat = "@"
                .Range("L:L").NumberFormat = "@"
            End If
        End With
    Next

End Sub

Open in new window

0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
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.
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.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

722 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