Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 49948

Compile Error "End With without With"

$
0
0
I am getting a "Compile Error" on the VBA code below, that says "End With without With".
Then it highlights a line in my code at the bottom area. (See where I labeled it with <<< below, on the code)
What am I doing wrong / missing?

Code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    Const WS_RANGE As String = "a1:bu1450"    '<=== change to suit

    If Target.Count > 1 Then Exit Sub
    If Not Target.Offset(, -1).Value Like "[qwertyui]" Then Exit Sub

    Application.EnableEvents = False

    If Not Application.Intersect(Target, Range(WS_RANGE)) Is Nothing Then
        With Target
            Select Case .Offset(, -1).Value
                Case "q":
                    .Font.Name = "x"
                    .Value = IIf(.Value = "x", "", "x")
                Case "w":
                    .Font.Name = "Wingdings 2"
                    .Value = IIf(.Value = "t", "", "t")
                Case "e":
                    .Font.Name = "FE"
                    .Value = IIf(.Value = "FE", "", "FE")
                Case "r":
                    .Font.Name = "RN"
                    .Value = IIf(.Value = "RN", "", "RN")
                Case "t":
                    .Font.Name = "m"
                    .Value = IIf(.Value = "MN", "", "MN")
                Case "y":
                    .Font.Name = "NI"
                    .Value = IIf(.Value = "NI", "", "NI")
                Case "u":
                    .Font.Name = "Y"
                    Select Case .Value
                        Case "Yes": .Value = "No"
                        Case "No": .Value = "Maybe"
                        Case "Maybe": .Value = "Never"
                        Case "Never": .Value = ""
                        Case "": .Value = "Yes"
                Case "i":
                    .Font.Name = "i"
                    Select Case .Value
                        Case "One": .Value = "Two"
                        Case "Two": .Value = "Three"
                        Case "Three": .Value = ""
                        Case "": .Value = "One"
                    End Select
            End Select
            .Offset(0, -1).Activate
           
        End With  <<< De Bugger Highlights This Line
    End If

    Application.EnableEvents = True

End Sub


Viewing all articles
Browse latest Browse all 49948

Trending Articles