End with without with message

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,731
Office Version
  1. 2007
Platform
  1. Windows
I have the code below which gives me the message End with without with.

On my worksheet i have 3 checkboxes.
Basically what i am trying to do is only clear the checkboxes if cell G13 has no value.
If cell G13 has a value then there will be a check mark in one of the checkboxes so leave it alone & dont clear it.

This is where now the message keeps popping up.

VBA Code:
Private Sub Workbook_Open()
Application.EnableEvents = False


With Sheets("INV")
If Range("G13").Value = "" Then
    .CheckBox1 = False
    .CheckBox2 = False
    .CheckBox3 = False
    .Range("G21:G23").Value = ""
    .Range("G21").Interior.ColorIndex = 2
    .Range("G21:G23").Borders.LineStyle = xlNone
End With
End If

Application.EnableEvents = True
    Range("G13:G18,G27:G36,G46:G50").HorizontalAlignment = xlCenter
    Range("G13:G18,G27:G36,G46:G50").VerticalAlignment = xlCenter
End Sub
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
You need to End If before you End With. Also .Range instead of Range

VBA Code:
With Sheets("INV")
    If .Range("G13").Value = "" Then
        .CheckBox1 = False
        .CheckBox2 = False
        .CheckBox3 = False
        .Range("G21:G23").Value = ""
        .Range("G21").Interior.ColorIndex = 2
        .Range("G21:G23").Borders.LineStyle = xlNone
    End If
End With
 
Upvote 0
Solution

Forum statistics

Threads
1,223,882
Messages
6,175,166
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top