Solved

Excel VBA Format Text

Posted on 2014-04-07
3
372 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
  • 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 500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

825 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