View Single Post
 
Old 12-01-2022, 11:57 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Not only are you missing the required final 'End With', your 'With .Range("B3:B6") ... End With' block is logically inside your 'With Range("A3:A6") ... End With' block. All this would be readily apparent if you structured your code more consistently and avoided 'With ... End With' blocks containing only one element. For example:
Code:
Sub Formatting()
With Worksheets("Formatting")
    With .Range("A1")
        .Value = "Expenses For March"
        With .Font
            .Name = "Arial"
            .Bold = True
            .ColorIndex = 5
            .Size = 14
        End With
        .Interior.ColorIndex = 2
        .HorizontalAlignment = xlLeft
    End With
    
    With .Range("A3:A6")
        .InsertIndent 1
        With .Font
            .Italic = True
            .Bold = True
            .ColorIndex = 3
        End With
    End With
    
    With .Range("B3:B6")
        .Interior.ColorIndex = 37
        .NumberFormat = "$#,##0"
    End With
End With
End Sub
Your 'With Range("A3:A6") ... End With' block should also be 'With .Range("A3:A6") ... End With'.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote